[R] Strange julian and/or strptime
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri May 23 11:41:03 CEST 2008
On my Linux box:
> strptime("010169", format = "%d%m%y")
[1] "1969-01-01"
> strptime("311268", format = "%d%m%y")
[1] "2068-12-31"
>From the help page:
'%y' Year without century (00-99). If you use this on input, which
century you get is system-specific. So don't! Often values
up to 69 (or 68) are prefixed by 20 and 70 (or 69) to 99 by
19.
If all else fails, read the documentation (but the posting guide asks you
to do that before posting). Elsewhere on that help page it refers you to
your OS documentation -- the posting guide asked for your OS 'at a
minimum', but as you didn't follow it so we have no idea which you used.
On Fri, 23 May 2008, Kåre Edvardsen wrote:
> Hi r-helpers...
>
> Why do I get this strange huge jump of 36524 days when changing "origin"
> from 1969-01-01 to 1968-12-31. It should still be close to zero! This
> really messes up my calculations of follow-up times in my analyses.
>
>> julian(strptime("010169", format = "%d%m%y"),origin =
> as.Date("1969-01-01"))
>> Time difference of -0.04166667 days
>
>> julian(strptime("311268", format = "%d%m%y"),origin =
> as.Date("1968-12-31"))
>> Time difference of 36524.96 days
>
>
> Cheers,
> Kare
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
--
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