| sort_levels | 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  | 
| fun | function to use to summarize groups of  | 
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.