This did the trick as.numeric(diff(c(ISOdatetime(2011,6,1,11,59,1.09),ISOdatetime(2011,6,5,11,59,1.09)))) [1] 345600
________________________________ From: Jim Holtman <jholt...@gmail.com> Cc: "R-help@r-project.org" <R-help@r-project.org> Sent: Monday, October 10, 2011 9:26 AM Subject: Re: [R] Handling Time in R check the help page; there is a parameter ('units' I thnk) that will let you specify that. Sent from my iPad Thanks a lot. > >That helped. >One thing now is to have the difftime(y,x) to always report seconds. There are >times that there is a change in the day and thus the diff will report few days >difference. How can it always report only seconds? > > >I would like to thank you in advance for your help > > >B.R >Alex > > > > >________________________________ >From: jim holtman <jholt...@gmail.com> >Cc: "R-help@r-project.org" <R-help@r-project.org> >Sent: Friday, October 7, 2011 5:34 PM >Subject: Re: [R] Handling Time in R > >?ISOdatetime > > >> x <- ISOdatetime(2011,10,6,16,23,30.539) >> str(x) >POSIXct[1:1], format: "2011-10-06 16:23:30" >> y <- ISOdatetime(2011,10,6,16,23,30.939) >> difftime(y,x) >Time difference of 0.3999999 secs >> > > >> Dear all, >> I would like to ask your help regarding handling time stamps in R. I think >> first I need a reference to read about their logic and how I should handle >> them. >> >> For example, this is a struct I have >> >> >> str(MyStruct$TimeStamps) >> num [1:100, 1:6] 2011 2011 2011 2011 2011 ... >> >> MyStruct$TimeStamps[1,] >> [1] 2011.000 10.000 6.000 16.000 23.000 30.539 >> >> the last field contains seconds.milliseconds. >> >> How I can for example make calculations with time stamps like see if the >> MyStruct$TimeStamps[1,]-MyStruct$TimeStamps[2,] differ more than >> 300millisecond, or 3 days have passed? >> >> I would like to thank you in advance for your suggestions >> >> B.R >> Alex >> >> [[alternative HTML version deleted]] >> >> >> ______________________________________________ >> R-help@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. >> >> > > > >-- >Jim Holtman >Data Munger Guru > >What is the problem that you are trying to solve? > > > [[alternative HTML version deleted]]
______________________________________________ R-help@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.