?difftime > difftime(strptime(a,format='%Y-%m-%dT%H:%M'), strptime(b,format='%Y-%m-%dT%H:%M')) Time difference of -41.06944 days > difftime(strptime(a,format='%Y-%m-%dT%H:%M'), strptime(b,format='%Y-%m-%dT%H:%M'), units = 'hours') Time difference of -985.6667 hours >
On Fri, Aug 9, 2013 at 1:37 PM, Jun Shen <jun.shen...@gmail.com> wrote: > Hi all, > > I used strptime() to convert character strings to time and did some > subtraction calculation. > > a<-'2012-07-17T07:50' > b<-'2012-08-27T09:30' > > strptime(a,format='%Y-%m-%dT%H:%M')-strptime(b,format='%Y-%m-%dT%H:%M') > > The result shows > > Time difference of -41.06944 days. > > However when these operations performed in a dataframe, the time difference > is in the unit of seconds. Why is that? What I really want is in hours. I > know I can convert the results manually to hours but just wonder if there > is way to control the unit. Thanks. > > Jun > > [[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? Tell me what you want to do, not how you want to do it. [[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.