fct_reorder: Reorder factor levels by sorting along another variable

View source: R/utils_fct_reorder.R

fct_reorderR Documentation

Reorder factor levels by sorting along another variable

Description

fct_reorder() is useful for 1d displays where the factor is mapped to position; fct_reorder2() for 2d displays where the factor is mapped to a non-position aesthetic. last2() and first2() are helpers for fct_reorder2(); last2() finds the last value of y when sorted by x; first2() finds the first value.

Usage

fct_reorder(.f, .x, .fun = median, ..., .desc = FALSE)

Arguments

.f

A factor (or character vector).

.x

The levels of f are reordered so that the values of .fun(.x) are in ascending order.

.fun

summary function. It should take one vector

...

Other arguments passed on to .fun. A common argument is na.rm = TRUE.

.desc

Order in descending order?

Details

Reimplements forcats::fct_reorder()


The-Strategy-Unit/723_mh_covid_surge_modelling documentation built on April 13, 2022, 8:52 a.m.