R/utils_fct_reorder.R
fct_reorder.Rd
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.
fct_reorder(.f, .x, .fun = median, ..., .desc = FALSE)
.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? |
Reimplements forcats::fct_reorder()