[R] Rearranging variables in table in non-alphabetical (manually specified) order
André Júng
andjun0 at web.de
Sun May 8 17:10:24 CEST 2011
Dear all,
I'm trying to rearrange variables in a table in a custum order for using it with levelplot. So far I could only find examples showing how to sort alphabetically. Here is a short example:
a <- c("Anna","Anna","Michael","Klaus","Klaus","Anna","Fritz")
b <- c("Schnitzel","Pommes","Pommes","Schnitzel","Wurst","Schnitzel","Schnitzel")
food <- matrix(c(a,b),7)
as.data.frame(food) -> tmp
as.data.frame(table(tmp)) -> X
levelplot(X$Freq ~ X$V1 * X$V2,xlab="people",ylab="food")
Food is now ordered: Pommes, Schnitzel, Wurst.
But I need: Schnitzel, Pommes, Wurst.
How can I define the order? I'm happy about every suggestion.
Thanks in advance!
Andre
___________________________________________________________
Schon gehört? WEB.DE hat einen genialen Phishing-Filter in die
More information about the R-help
mailing list