Hi all, I have time data in the following format: 2009-03-09 12:00:00 2009-03-09 13:30:00 Now I want to compute the delta between the two time points, which results in this example in 1,5 h. I tried this via "ts" and the related functions but so far without sucess. Can anybody help me? Thank you very much in advance. -- View this message in context: http://www.nabble.com/Delta-in-time-series-tp23957835p23957835.html Sent from the R help mailing list archive at Nabble.com.
koj wrote:> > Hi all, > > I have time data in the following format: > > 2009-03-09 12:00:00 > 2009-03-09 13:30:00 > > Now I want to compute the delta between the two time points, which results > in this example in 1,5 h. I tried this via "ts" and the related functions > but so far without sucess. Can anybody help me? > > Thank you very much in advance. > > > >Probably this is of interest for another users: I`ve found a solution, which computes the delta: (test<-strptime(c(jens1$Z_Zeit[1], jens1$Z_Zeit[2]),"%Y-%m-%d %H:%M:%S", tz="EST5EDT")) class(test) difftime(test[2],test[1],units="hours",tz="EST5EDT") -- View this message in context: http://www.nabble.com/Delta-in-time-series-tp23957835p23959207.html Sent from the R help mailing list archive at Nabble.com.
Try this:> library(zoo) > Lines <- "2009-03-09 12:00:00,1+ 2009-03-09 13:30:00,2"> z <- read.zoo(textConnection(Lines), sep = ",", tz = "") > 1/frequency(as.zooreg(z))[1] 5400 noting that 5400 seconds is 1.5 hours. On Wed, Jun 10, 2009 at 5:04 AM, koj<jens.koch at gmx.li> wrote:> > Hi all, > > I have time data in the following format: > > 2009-03-09 12:00:00 > 2009-03-09 13:30:00 > > Now I want to compute the delta between the two time points, which results > in this example in 1,5 h. I tried this via "ts" and the related functions > but so far without sucess. Can anybody help me? > > Thank you very much in advance. > > > > -- > View this message in context: http://www.nabble.com/Delta-in-time-series-tp23957835p23957835.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >