[R] Trouble: Time Difference with difftime
Jim Trabas
jim.trabas at googlemail.com
Sun Aug 14 15:33:04 CEST 2011
Hello all!!!
I want to measure the duration of events (given a start and an end time).
The catch is that I require the output in calender days. This means:
02-Jan-2011 00:01:00 minus 01-Jan-2011 23:59:00 should be 1 day (although
the real time difference is only 2 minutes)
My data is the following
head(episode.ct)
[1] "2009-07-13 13:37:20 CEST" "2009-07-14 07:29:20 CEST" "2009-07-14
07:51:20 CEST" "2009-07-14 08:45:20 CEST"
[5] "2009-07-14 09:43:20 CEST" "2009-07-14 10:01:20 CEST"
head(episode.end.ct)
[1] "2009-07-13 13:47:20 CEST" "2009-07-14 07:49:20 CEST" "2009-07-14
08:01:20 CEST" "2009-07-14 08:53:20 CEST"
[5] "2009-07-14 09:51:20 CEST" "2009-07-14 10:11:20 CEST"
attributes(episode.ct)
$class
[1] "POSIXct" "POSIXt"
$tzone
[1] ""
attributes(episode.end.ct)
$class
[1] "POSIXct" "POSIXt"
$tzone
[1] ""
When I try :
> difftime(episode.ct-episode.end.ct)
I get
Error in as.POSIXct.default(time1) :
do not know how to convert 'time1' to class "POSIXct"
Why is that? Is difftime what I need?
Thank you very much
JT
--
View this message in context: http://r.789695.n4.nabble.com/Trouble-Time-Difference-with-difftime-tp3742847p3742847.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list