Hi all, 
   I think this might be an easy one but I cannot think of a way to do this
other than what I am currently attempting.  I simply want to sort my data
frame's rownames by a defined vector so that the plots I generate from that
vector are in the desired order 

Consider the test data below:

#Create test data       
        DataToPlot.. <- data.frame("Location1" = c(100,200),"Location2" =
c(200,400))
        #Name rowns
        rownames(DataToPlot..) <- c("Fall","Summer")
        #Attempt to coerce row names to factors 
        rownames(DataToPlot..) <- as.factor(rownames(DataToPlot..))
        #Attenmpt to sort rownames by defined vector
        rownames(DataToPlot..)<- reorder(as.factor(rownames(DataToPlot..)),
new.order = c("Summer","Fall","Winter","Spring"))
                
The rownames do not reorder nor do they remain factors.  

Perhaps I can just sort these in the plot?  Not sure whats easier/possible?

barchart(DataToPlot..SeCl , horizontal = FALSE, ylab = "Average Weekday
Counts",
                        group = colnames(DataToPlot..SeCl ), col =
Colors.[rownames(DataToPlot..SeCl)] )
                

Thanks for any help.

Josh



--
View this message in context: 
http://r.789695.n4.nabble.com/Coerce-rownames-to-factor-for-ordering-tp4651330.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