fct_drop_levels: Drop unused levels

Description Usage Arguments See Also Examples

Description

Wrapper around forcats drop_levels which will not modify or drop non-level attributes. Compared to 'base::droplevels()' does not drop 'NA' levels that have values.

Usage

1
fct_drop_levels(f, only)

Arguments

f

A factor

only

A character vector restricting the set of levels to be dropped. If supplied, only levels that have no entries and appear in this vector will be removed.

See Also

fct_drop

Examples

1
2
3
4
5
6
7
f <- factor(c("a", "b"), levels = c("a", "b", "c"))
f
fct_drop_levels(f)

# Set only to restrict which levels to drop
fct_drop_levels(f, only = "a")
fct_drop_levels(f, only = "c")

dpavlic/EPmisc documentation built on May 15, 2019, 1:45 p.m.