Add additional levels to a factor
fct_expand(f, ...)
f | A factor (or character vector). |
---|---|
... | Additional levels to add to the factor. Levels that already exist will be silently ignored. |
fct_drop()
to drop unused factor levels.
#> [1] b b a b c b b a c a b c b c c c b c b a #> Levels: a b cfct_expand(f, "d", "e", "f")#> [1] b b a b c b b a c a b c b c c c b c b a #> Levels: a b c d e ffct_expand(f, letters[1:6])#> [1] b b a b c b b a c a b c b c c c b c b a #> Levels: a b c d e f