[R] Converting the data in year month day hour and minutes to date
John Kane
jrkrideau at inbox.com
Tue Feb 19 20:25:25 CET 2013
You need to convert the factor to character.
as.Date( as.character(mydata$Date), "%Y-%m-%d")
should do it.
John Kane
Kingston ON Canada
> -----Original Message-----
> From: janesh.devkota at gmail.com
> Sent: Tue, 19 Feb 2013 11:47:04 -0600
> To: r-help at r-project.org
> Subject: [R] Converting the data in year month day hour and minutes to
> date
>
> Hi ,
>
>
>
> I am trying to convert the date as factor to date using "as.date"
> function
> in R. I have the date in the following format
>
> 2008-01-01 02:30
>
>
>
> I tried to use the following command :
>
> as.Date(mydata$Date, format="%y-%m-%d ")
>
>
>
> Can somebody help me with this ? I was able to convert the format with no
> hour but getting difficulty with hour included.
>
>
>
> Thank you.
>
>
>
> Janesh
>
>
> [[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.
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
More information about the R-help
mailing list