sort.levels {mining} | R Documentation |
The levels of a factor are sorted according to a summary statistic.
sort.levels(f,x,fun=median)
f |
a factor |
x |
a vector, same length as f |
fun |
function to use to summarize groups of x |
A copy of f
with re-ordered levels.
Tom Minka
data(OrchardSprays) sort.levels(OrchardSprays$treatment, OrchardSprays$decrease) sort.levels(OrchardSprays$treatment, OrchardSprays$decrease, fun=mean)