问题
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