是否有一种更有效/更优雅的方法来执行以下操作,其中我连接输出的Sys.time()
输出中的所有数字
x <- as.character(Sys.time())
paste0(substr(x,0,4),substr(x,6,7),substr(x,9,10),substr(x,12,13),substr(x,15,16),substr(x,18,20))
Run Code Online (Sandbox Code Playgroud)
它可能包括粘贴和崩溃,但不知道如何做到这一点......
您可以使用格式文字strftime()
将POSIXct
对象转换为字符:
strftime(Sys.time(), "%Y%m%d%H%M%S")
[1] "20120910061602"
Run Code Online (Sandbox Code Playgroud)
有关?strftime
要使用的字符串文字的详细信息,请参阅.
我原本以为format
是第一选择:
format(Sys.time(), "%Y%m%d%H%M%S")
[1] "20120909231732"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
108 次 |
最近记录: |