[R] strange conversion char to date

jim holtman jholtman at gmail.com
Fri Aug 30 18:32:32 CEST 2013


Take a look at the documentation as to what "%y" means:

    ‘%y’ Year without century (00-99).  On input, values 00 to 68 are
          prefixed by 20 and 69 to 99 by 19 - that is the behaviour
          specified by the 2004 and 2008 POSIX standards, but they do
          also say ‘it is expected that in a future version the default
          century inferred from a 2-digit year will change’.

This is due to the Y2K problem that maybe you never had to deal with.
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Fri, Aug 30, 2013 at 9:12 AM, Frans Marcelissen
<frans.marcelissen at digipsy.nl> wrote:
> Hi R-friends,
> Can anyone explain the following strange behavior to me?
>> as.Date( "4/25/71","%m/%d/%y")
> [1] "1971-04-25"
>> as.Date( "4/25/62","%m/%d/%y")
> [1] "2062-04-25"
>
> so 71 is converted to 1971, while 62 is converted to 2062? Does anyone know
> why? And is there a simple way to specify the date?
> (does works the same way in R 2.01 as well as in 1.9)
>
> -------------------
> dr F.H.G. (Frans) Marcelissen
> DigiPsy (www.DigiPsy.nl <http://www.digipsy.nl/>)
> Pomperschans 26
> 5595 AV Leende
> tel: 040 2065030/06 2325 06 53
> skype adres: frans.marcelissen
> email: frans.marcelissen at digipsy.nl
>
>         [[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.



More information about the R-help mailing list