sig*_*ker 78 datetime r time-series strptime
我如何使用strptime
或任何其他函数来解析R中的毫秒时间戳?
time[1]
# [1] "2010-01-15 13:55:23.975"
strptime(time[1], format="%Y-%m-%d %H:%M:%S.%f")
# [1] NA
strptime(time[1], format="%Y-%m-%d %H:%M:%S")
# [1] "2010-01-15 13:55:23"`
Run Code Online (Sandbox Code Playgroud)
Ani*_*iko 109
礼貌的?strptime
帮助文件(示例更改为您的值):
z <- strptime("2010-01-15 13:55:23.975", "%Y-%m-%d %H:%M:%OS")
z # prints without fractional seconds
op <- options(digits.secs=3)
z
options(op) #reset options
Run Code Online (Sandbox Code Playgroud)
dar*_*s0n 29
你也可以使用strptime(time[1], "%OSn")
0 <= n <= 6的地方,而不必设置digits.secs
.