One possible (but not very elegant) solution is: > aa <- paste(1:12,":10:2009",sep="") > dd<-as.Date(aa,format="%m:%d:%Y") > mon <- format(dd,"%b") > mon [1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"
--- On Thu, 20/8/09, Liviu Andronic <landronim...@gmail.com> wrote: > From: Liviu Andronic <landronim...@gmail.com> > Subject: [R] expanding 1:12 months to Jan:Dec > To: "r-help@r-project.org Help" <r-help@r-project.org> > Received: Thursday, 20 August, 2009, 5:14 PM > Dear R users > I would like to do some spreadsheet style expansion of > dates. For > example, I would need to obtain a vector of months. I > approached in an > obviously wrong way: > > paste(01:12) > [1] "1" "2" "3" "4" "5" > "6" "7" "8" "9" "10" "11" "12" > > as.Date(paste(01:12), "%m") > [1] NA NA NA NA NA NA NA NA NA NA NA NA > > to subsequently format(.., "%b"). Other than writing the > months > manually, could anyone suggest an easier way to obtain such > a list? > Liviu > > > > > -- > Do you know how to read? > http://www.alienetworks.com/srtest.cfm > Do you know how to write? > http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.