[R] Is there any "month" object like "LETTERS" ?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Sep 11 11:47:05 CEST 2009


On Fri, Sep 11, 2009 at 8:13 AM, megh <megh700004 at yahoo.com> wrote:
>
> There is an object "LETTERS" which displays all letters from "a" to "z". Is
> there any similar object whicg displays the "months" as well in
> chronological order? like "jan", "feb",...........,"dec"

 You could construct a vector of the first of the month for some year
and then use months() or format() on it:

 > months(ISOdatetime(1960,1:12,1,0,0,0))
  [1] "January"   "February"  "March"     "April"     "May"       "June"
  [7] "July"      "August"    "September" "October"   "November"  "December"

 > format(ISOdatetime(1960,1:12,1,0,0,0),"%b")
  [1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"

 Note these are locale-dependent, so les Francais will see something
else. Probably "Jan","Fev","Mar","Avr" and so on...

Barry




More information about the R-help mailing list