[R] Changing string to date
PIKAL Petr
petr.pikal at precheza.cz
Fri Aug 30 12:19:37 CEST 2013
Hi
as.Date(paste("MAY-14","-01", sep=""), format = "%b-%y-%d")
Shall be OK. Change output format by ?format.
Regards
Petr
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Christofer Bogaso
> Sent: Friday, August 30, 2013 12:00 PM
> To: r-help
> Subject: [R] Changing string to date
>
> Hello again,
>
> I have a string which I need to put in some legitimate date format.
>
> My string is: "MAY-14"
>
> And output format would be "05/01/2014", this should be of Date class,
> so that I can make some sensible calculation with it.
>
> I have tried this without any success:
>
> > as.Date("MAY-14", format = "%b-%y")
> [1] NA
>
>
> Can somebody help me how I can achieve that?
>
> Thanks and regards,
>
> ______________________________________________
> 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