desc_reorder: Reorder levels of a factor according to some corresponding...

Description Usage Arguments Value Examples

Description

Reorder levels of a factor according to some corresponding numeric values in descending order

Usage

1
desc_reorder(x, y, fun = mean)

Arguments

x

A vector of class factor to be reordered

y

A numeric vector

fun

a function whose first argument is a vector and returns a scalar, to be applied to each subset of x determined by the levels of y

Value

A factor with desired reordered levels

Examples

1
2
boxplot(Sepal.Width ~ Species, data = iris)
boxplot(Sepal.Width ~ desc_reorder(Species, Sepal.Width), data = iris)

MaryHe/First-Package-of-Mary documentation built on May 7, 2019, 3:40 p.m.