[R] Plotting Factors -- Sorting x-axis

David Winsemius dwinsemius at comcast.net
Fri Jan 7 05:57:00 CET 2011


On Jan 6, 2011, at 6:13 PM, Taylor, Eric HLS:EX wrote:

> Hello;
>
> How do I plot these data in R without the Months being ordered  
> alphabetically?
>
>   Months Prec
> 1     Jan   102.1
> 2     Feb    69.7
> 3     Mar    44.7
> 4     Apr    32.1
> 5     May    24.0
> 6     Jun    18.7
> 7     Jul    14.0
> 8     Aug    20.0
> 9     Sep    32.4
> 10    Oct    58.9
> 11    Nov    94.5
> 12    Dec   108.2

Since they are most likely factor variables (but even if not):

dfrm$Months <- factor(dfrm$Months, levels= month.abb)

Then the level ordering will be as expected.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list