Hello all, 
   I cannot seem to figure out this seemingly simple procedure.  

I want to sort a data frame by a specified character vector.

So for :

df.. <- data.frame(Season=rep(c("Summer","Fall","Winter","Spring"),4),Obs=
runif(length(rep(c("Summer","Fall","Winter","Spring"),4))))

I want to sort the data frame by the seasons but in the order I specify
since alphapetically would not put the season in sequential order

I tried the following and a few other things but no dice.  It looks like I
will have to convert to factors.  Any thoughts?  Thanks

df.. <-
df..[sort(as.factor(Df..$Season,levels=c("Summer","Fall","Winter","Spring"))),]

Josh



--
View this message in context: 
http://r.789695.n4.nabble.com/Sorting-a-data-frame-by-specifying-a-vector-tp4645867.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to