[R] as.date - german date format
ligges at statistik.tu-dortmund.de
Wed Jan 9 18:18:29 CET 2008
> Uwe Ligges-3 wrote:
>> Konga wrote:
>>> I have a data.frame with the following variable:
>>> $ xx :Factor w/ 66 levels "01.02.2006","01.03.2006",..: 3 3 3 3 3 3 3 3
>>> now I´d like use "as.date" on it - if I comprehend the instructions on
>>> it should work like this:
>>> as.date(xx, "%d.%m.%Y") - but it doesn´t...
>> What is the error message?
>> - Fehler in as.date(mydata$xx, "%d.%m.%Y") :
>> Cannot coerce to date format
I see, so this is really as.data() from the survival package.
>> Which R version is this?
>> What are all the
>> labels (in order to reproduce your error)?
>> - The data.frame has 1500 objects - do you want me to print them all? Even
>> the 66 different levels of the factor would be a little bit much, I think.
>> But I printed them once, they all have the same format.
The data.frame has 1500 rows but the factor just 66 labels. You could
have made it available from some web server.
Anyway, you could try
as.date(format(as.Date(mydata$xx, "%d.%m.%Y"), "%m/%d/%Y"))
instead (discussion open for better ideas!).
>> in order to get better help.
>> Uwe Ligges
>>> the survival Package ist loaded - is there a problem with the german
>>> Or did I understand something wrong?
>>> Much better than tranforming the format from to data would be to import
>>> in the right format.
>>> Is there a parameter for read.csv to get it as a date from the beginning?
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help