Control POSIX time difference output in R

馋奶兔 提交于 2021-02-06 02:35:38

问题


In R I have two strings:

t <- c("2010-01-01 00:01:02", "2010-01-01 00:02:02")

which I convert to POSIX datetimes:

dt <- as.POSIXct(t)

Taking the difference of the two dt[2] - dt[1] gives:

Time difference of 1 mins

Cool. But how do I force the time difference to be in, say, seconds?


回答1:


> difftime(dt[2], dt[1], units="secs")
Time difference of 60 secs


来源:https://stackoverflow.com/questions/7492247/control-posix-time-difference-output-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!