Description Usage Arguments See Also Examples
View source: R/tidyverse-extras.R
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.
1 | fct_drop_levels(f, only)
|
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. |
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.