[R] Creating dates to plot

PIKAL Petr petr.pikal at precheza.cz
Fri Nov 16 09:23:59 CET 2012


Hi

x$dat <- as.Date(paste(x$Period,0,1, sep=""), format="%Y%m%d")

shall do it.
Petr

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of eric
> Sent: Friday, November 16, 2012 12:46 AM
> To: r-help at r-project.org
> Subject: [R] Creating dates to plot
> 
> I have a dataframe that looks like this:
> 
> head(x)
>   Period      AP             Al                MA             BB
> All
> 1 200812  903,231   1,985,460   905,422   3,312,088   7,106,201
> 2 200901  880,491   1,924,111   892,980   3,006,050   6,703,631
> 3 200902  883,994   1,926,169   890,021   3,247,530   6,947,714
> 4 200903  888,021   1,901,182   892,593   3,216,730   6,898,526
> 5 200904  869,024   1,829,841   857,723   3,121,458   6,678,046
> 6 200905  847,450   1,776,100   847,593   3,110,783   6,581,925
> 
> x$Period is a numeric value that represents the year and month. How
> would I take those values and turn them into dates so that I could plot
> the various columns vs the date ?
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Creating-
> dates-to-plot-tp4649677.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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