Re: [R] Replace number with month

From: Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk>
Date: Thu, 21 Jun 2007 10:15:30 +0200

Don MacQueen wrote:
> You can get the names using
>
> month.name[MM]
>
>
> And it may be necessary to use
>
> factor(month.name[MM], levels=month.name[1:12])
>
> to get them to show up in the correct order in the barchart.
>

You're crossing the creek to fetch water there, and getting yourself soaked in the process... (by an unnecessary conversion to character which is subject to alphabetical sorting)

I think the canonical way is

factor(MM, levels=1:12, labels=month.name)

(and the levels=1:12 may not even be necessary when all 12 months are present)

-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help_at_stat.math.ethz.ch 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.
Received on Thu 21 Jun 2007 - 08:21:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Jun 2007 - 08:32:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.