【问题标题】:Remove the leading brackets when used print in r在 r 中使用 print 时删除前括号
【发布时间】:2018-10-10 03:17:27
【问题描述】:

我想在 r 中打印不带前括号的 Sys.time()。

例如:

print(sprintf("Triggered at: %s", Sys.time()),quote = FALSE)

输出:

[1] Triggered at: 2018-04-30 10:51:12

但我想要的结果是

Triggered at: 2018-04-30 10:51:12

我试过用 cat 来做这个,但没用,

cat(Sys.time())

输出

1525058622

【问题讨论】:

    标签: r printing cat


    【解决方案1】:

    你快到了。试试

    cat(sprintf("Triggered at: %s\n", Sys.time()))
    #Triggered at: 2018-04-30 13:27:50
    

    【讨论】:

    • 效果很好,我浪费了 1 个多小时。谢谢!很快就会接受答案(10 分钟后),这是一个系统约束。
    • “我浪费了超过 1 个多小时。” 也去过那里 @Toros91;-)
    • 还有message - message(paste0("Triggered at: ", Sys.time()))
    • @SymbolixAU:谢谢,这很有趣。将保留此以备将来使用。
    猜你喜欢
    • 1970-01-01
    • 2017-03-25
    • 2013-11-09
    • 2019-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-28
    相关资源
    最近更新 更多