[R] difftime

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Dec 9 19:17:27 CET 2008


In the absence of any of the information requested in the posting guide, 
all we can say is that this works for other people (e.g. on both Mac OS X 
and Fedora 8 for me).

Apart from the usual info, we would need to know your timezone.

On Tue, 9 Dec 2008, eric lee wrote:

> Hi.  I'm trying to take the difference in days between two times.  Can
> you point out what's wrong, or suggest a different function?  When I
> try the following code,  The following code works fine:
>
> a <- strptime(1911100807,format="%Y%m%d%H",tz="GMT")
> b <- strptime(1911102718,format="%Y%m%d%H",tz="GMT")
> x <- difftime(b, a, units="days")
> x
>
>
> But when I change the year, the following code returns 'NA' for the
> time between a and b.  Thanks.
>
> a <- strptime(1999100807,format="%Y%m%d%H",tz="GMT")
> b <- strptime(1999102718,format="%Y%m%d%H",tz="GMT")
> x <- difftime(b, a, units="days")
> x
>
> ______________________________________________
> R-help at 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.

PLEASE do.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list