Hi:
First of all, look at
str(dataframename)
It sounds as though you need to convert Month to an ordered factor,
something
like
df$Month <- ordered(df$Month, levels = month.abb)
df$Month
The second command is to check that the newly created factor orders the
months
appropriately. Here's a small example:
> tst <- data.frame(m = month.abb, y = rnorm(12))
> str(tst)
'data.frame': 12 obs. of 2 variables:
$ m: Factor w/ 12 levels "Apr","Aug","Dec",..: 5
4 8 1 9 7 6 2 12 11 ...
$ y: num -0.269 0.0125 0.4868 -0.4784 -0.2618 ...> tst$m
[1] Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Levels: Apr Aug Dec Feb Jan Jul Jun Mar May Nov Oct Sep> tst$m <- ordered(tst$m, levels = month.abb)
> tst$m
[1] Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
12 Levels: Jan < Feb < Mar < Apr < May < Jun < Jul < Aug
< Sep < ... <
Dec <<===> q <- ggplot(tst, aes(x = m, y =
y))> q + geom_point(size = 2) + geom_line(aes(group = 1))
HTH,
Dennis
On Tue, May 11, 2010 at 7:44 PM, michael westphal
<mi_westphal@yahoo.com>wrote:
> Hello:
>
> I have a dataframe, where the first column in a month:
>
> Month CATCHMENT_ med min max
> 1 Apr Alknda01 71.68080 11.9406600 196.2753
> 2 Apr Alknda02 69.44580 12.1065600 196.2753
> 3 Apr ArialKhan 39.89310 5.8598700 175.4433
> 4 Apr Arjun01 4.79652 0.0093336 55.7136
> 5 Apr Arjun02 4.79652 0.0093336 55.7136
> 6 Apr Arun01 52.42320 0.1571928 241.9566
> 7 Apr Arun02 31.05060 0.1738902 420.6930
> 8 Apr Atrai01 52.58640 2.2828830 190.8891
> 9 Apr Atrai02 51.98850 2.6499780 189.7872
> 10 Apr Babai01 27.55440 0.0332469 130.7787
>
>
> I want to sort the rows by Month, not alphabetically, but in the calendar
> order. Any suggestions?
>
> Thanks,
>
> Michael
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
[[alternative HTML version deleted]]