继续:How R formats POSIXct with fractional seconds后,我有两个不同的(字符)时间戳,使用fastPOSIXct
包中的fasttime
转换为相同的POSIXct值:
library(fasttime)
tmpstmp <- c("2010-03-01 12:41:52.713",
"2010-02-01 12:41:52.714")
options(digits.secs = 6) # note that this is required to display fractional seconds in R.
fastPOSIXct(tmpstmp)
给
> fastPOSIXct(tmpstmp)
[1] "2010-03-01 23:41:52.713 AEDT" "2010-02-01 23:41:52.713 AEDT"
这是非常不受欢迎的行为。我的解决方法是连接10微秒,所以我现在有
tmpstmp <- c("2010-03-01 12:41:52.71301",
"2010-02-01 12:41:52.71401")
给
> fastPOSIXct(tmpstmp)
[1] "2010-03-01 23:41:52.71301 AEDT" "2010-02-01 23:41:52.71401 AEDT"
我现在想把这个POSIXct对象舍入到最接近的毫秒。我该怎么做?