Re: [R] The time unit of strptime() after performing arithmetic calculation

2013-08-09 Thread Jeff Newmiller
The printed view of a difftime object is not necessarily reflective of its internal representation. Also, to avoid unpleasant surprises always use a conversion function with specified units (not "auto") if you want to convert between numeric and difftime.

Re: [R] The time unit of strptime() after performing arithmetic calculation

2013-08-09 Thread MacQueen, Don
The Details section of the help page for difftime explains why. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 8/9/13 11:02 AM, "Jun Shen" wrote: >Thanks Jim and David, > >The difftime() is exactly what I am looking for. Ju

Re: [R] The time unit of strptime() after performing arithmetic calculation

2013-08-09 Thread Jun Shen
Thanks Jim and David, The difftime() is exactly what I am looking for. Just out of curiosity why the unit of output is different. here is an example of the dataframe. test<-structure(list(SPDTC = c("2012-08-27T09:30", "2012-08-06T10:08", "2012-08-13T07:41", "2012-07-17T07:50", "2012-09-11T10:29")

Re: [R] The time unit of strptime() after performing arithmetic calculation

2013-08-09 Thread David Winsemius
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 resul

Re: [R] The time unit of strptime() after performing arithmetic calculation

2013-08-09 Thread jim holtman
?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

[R] The time unit of strptime() after performing arithmetic calculation

2013-08-09 Thread Jun Shen
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 opera