?reorder
Try:
> newstate <- reorder(state,state, length)
Or
> newstate <- reorder(state,state, function(x) -length(x) )
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
> -Original Message-
> From:
Shoaaib Mehmood wrote:
> using an example from r online help
>
>
>>state <- c("tas", "sa", "qld", "nsw", "nsw", "nt", "wa", "wa",
>
> "qld", "vic", "nsw", "vic", "qld", "qld", "sa", "tas",
> "sa", "nt", "wa", "vic", "qld", "nsw", "nsw", "wa",
> "sa", "act", "nsw", "vic", "vic", "act"
one way is the following:
tb <- table(state)
statefac <- factor(state,
levels = names(tb[order(tb, decreasing = TRUE)]))
I hope it helps.
Best,
Dimitris
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvo
3 matches
Mail list logo