[R] Datetimes differences

bonneu@cict.fr bonneu at cict.fr
Wed Jan 11 17:53:51 CET 2006


I want to obtain datetime differences in mins in an other column, in front of my
datetimes. I have tried this :

T1 <- c("12/31/03 23:49","1/1/04 1:14","1/1/04 0:02")
T2 <- c("1/1/04 0:58","1/1/04 1:16","")
toto <- data.frame(T1,T2)
toto

y <- strptime(T1,"%m/%d/%y %H:%M")
x <- strptime(T2,"%m/%d/%y %H:%M")
difftime(x,y)


but, i don't know how can i do in order to obtain something like this :

ans <- c(69,2,NA)
res <- data.frame(T1,T2,ans)
res

what is to be done ?
Thanks.

Florent Bonneu
Laboratoire de Statistique et Probabilités
bureau 148  bât. 1R2
Université Toulouse 3
118 route de Narbonne - 31062 Toulouse cedex 9
bonneu at cict.fr




More information about the R-help mailing list