Compared to `base::droplevels()`

, does not drop `NA`

levels that have values.

fct_drop(f, only)

f | A factor (or character vector). |
---|---|

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. |

`fct_expand()`

to add additional levels to a factor.

#> [1] a b #> Levels: a b cfct_drop(f)#> [1] a b #> Levels: a b# Set only to restrict which levels to drop fct_drop(f, only = "a")#> [1] a b #> Levels: a b cfct_drop(f, only = "c")#> [1] a b #> Levels: a b