An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111117/b3ab0535/attachment.pl>
R help
3 messages · Arango, Ana, Shant Ch, David Winsemius
3 days later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111120/e25fe699/attachment.pl>
On Nov 20, 2011, at 10:46 PM, Shant Ch wrote:
Hi all,
I have a data set
containing dates in the format of m/d/y starting from 1950. I wanted
to
use standard format of date R uses. So I read the data set in R and
converted it using as.Dates. But for dates from 1950-1968, I have the
following problem.
as.Date("1/1/50","%m/%d/%y",origin="1900/01/01") ="2050-01-01"
instead of "1950-01-01"
But for dates 1969 onwards it is working fine.
As is documented in ?strptime %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?.
as.Date("1/1/69","%m/%d/%y") = "1969-01-01"
Perhaps some greppingg surgery?
> as.Date(sub("(.+/.+/)([0-6])", "\\119\\2", "1/1/69"),"%m/%d/%Y")
[1] "1969-01-01"
You have not really described the problem completely .... what is the
range of dates we need to work with? Do you have any "1/1/05" type
values and if so what century should be assumed?
Can anyone please help me find out the problem? Thanks Shant [[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.
David Winsemius, MD West Hartford, CT