[R] What determines the unit of POSIXct differences?

Heinz Tuechler tuechler at gmx.at
Fri Sep 11 13:50:45 CEST 2009


Dear All,

what determines if a difference between POSIXct objects gets 
expressed in days or seconds?
In the following example, it's sometimes seconds, sometimes days.

as.POSIXct('2009-09-01') - as.POSIXct(NA)
Time difference of NA secs

c(as.POSIXct('2009-09-01'), as.POSIXct(NA)) -
   c(as.POSIXct('2009-09-01'), as.POSIXct('2009-08-31'))
Time differences in secs
[1]  0 NA

c(as.POSIXct('2009-09-01'), as.POSIXct(NA)) -
   as.POSIXct('2009-08-31')
Time differences in days
[1]  1 NA

Thanks,
Heinz




More information about the R-help mailing list