On Aug 9, 2013, at 10:37 AM, Jun Shen 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.
?difftime ?`-.POSIXt` Should provide exactly what is requested (and is linked from the ?DateTimeClasses help page.) -- David Winsemius Alameda, CA, USA ______________________________________________ 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.