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.
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
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")
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
?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
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
6 matches
Mail list logo