Hi,
I am running the following -masked- code:
set.seed(23)
city <- sample(c("C1","C2"),size=100,replace=T)
reason <- sample(c("R1","R2","R3","R4"),size=100,replace=T)
df <- data.frame(city,reason)
library(gmodels)
CrossTable(df$reason,df$city,prop.r=F,prop.c=F,prop.t=F,prop.chisq=F)
And I get the following output:
| df$city
df$reason | C1 | C2 | Row Total |
-------------|-----------|-----------|-----------|
R1 | 4 | 13 | 17 |
-------------|-----------|-----------|-----------|
R2 | 19 | 10 | 29 |
-------------|-----------|-----------|-----------|
R3 | 12 | 13 | 25 |
-------------|-----------|-----------|-----------|
R4 | 11 | 18 | 29 |
-------------|-----------|-----------|-----------|
Column Total | 46 | 54 | 100 |
-------------|-----------|-----------|-----------|
I would like to have the df$reason sorted by decreasing count on the Row Total
- that is showing R2, R4, R3 and finally R1 - how can I do that?
Thanks,
Luca
Mr. Luca Meyer
www.lucameyer.com
R version 2.13.1 (2011-07-08)
Mac OS X 10.6.8
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.