[R] Replace number with month

Don MacQueen macq at llnl.gov
Thu Jun 21 00:48:32 CEST 2007


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.

Try, for example,

     plot(factor(month.name[1:12], levels=month.name[1:12]) , 12:1)

-Don

At 4:12 PM -0600 6/20/07, Spilak,Jacqueline [Edm] wrote:
>Hi all
>I have a multiple datasets that look like this
>
>MM  Freq
>  1      30
>   2     35
>   3     54
>   4     33
>   5     27
>   6     13
>   7     25
>   8     29
>   9     40
>   10   32
>   11   36
>   12   23
>
>I am plotting this using barchart (there is probably something better
>but it gives me the results I want) and I would like the x-axis to have
>the names of the months instead of the month numbers.  So I have
>searched and searched and I am not sure if I have to change it before I
>graph it or if I can somehow change it in barchart.  Any help is most
>appreciated.
>Jacquie
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>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.


-- 
---------------------------------
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
macq at llnl.gov



More information about the R-help mailing list