fct_reorg: Reorganize a factor after "re-leveling" it

View source: R/misc.R

fct_reorgR Documentation

Reorganize a factor after "re-leveling" it

Description

fct_reorg() is a forcats hack that reorganizes a factor after re-leveling it. It has been situationally useful in my coefficient plots over the years.

Usage

fct_reorg(fac, ...)

Arguments

fac

a character or factor vector

...

optional parameters to be supplied to forcats functions.

Details

Solution comes by way of this issue on Github: https://github.com/tidyverse/forcats/issues/45

Value

This function takes a character or factor vector and first re-levels it before re-coding certain values. The end result is a factor.

Examples


x<-factor(c("a","b","c"))
fct_reorg(x, B="b", C="c")


stevemisc documentation built on April 12, 2022, 5:06 p.m.