Learn R Programming

plotfunctions (version 1.4)

sortGroups: Sort groups based on a function such as mean value or deviation.

Description

Sort groups based on a function such as mean value or deviation.

Usage

sortGroups(formula, FUN = "mean", decreasing = FALSE, ...)

Arguments

formula

Formula for splitting the data

FUN

Function to apply to each group

decreasing

Logical: sort groups on decreasing values or not (default is FALSE, sorting on increasing values).

...

Additional arguments for the function aggregate.

Value

The order of levels.

See Also

Other Utility functions: findAbsMin(), find_n_neighbors(), firstLetterCap(), getArrowPos(), getDec(), getRange(), getRatioCoords(), get_palette(), group_sort(), inch2coords(), isColor(), list2str(), move_n_point(), orderBoxplot(), se()

Examples

Run this code
# NOT RUN {
head(ToothGrowth)
# sort on basis of mean length:
sortGroups(len ~ dose:supp, data = ToothGrowth)
labels = levels(interaction(ToothGrowth$dose, ToothGrowth$supp))
labels[sortGroups(len ~ dose:supp, data = ToothGrowth)]
# }

Run the code above in your browser using DataLab