Remove/reorder levels
refactor(x, levs = levels(x), repl = NA)
x | Character or Factor |
---|---|
levs | Set of levels to use |
repl | String (or NA) used to replace missing levels |
Keep only a specific set of levels in a factor. By removing levels the base for comparison in, e.g., regression analysis, becomes the first level. To relabel the base use, for example, repl = 'other'
#> [1] Ideal <NA> <NA> Ideal Premium Ideal #> Levels: Premium Ideal#> [1] Ideal Other Other Ideal Premium Ideal #> Levels: Other Premium Ideal