powered by
Add additional levels to a factor
fct_expand(f, ..., after = Inf)
A factor (or character vector).
Additional levels to add to the factor. Levels that already exist will be silently ignored.
Where should the new values be placed?
fct_drop() to drop unused factor levels.
fct_drop()
f <- factor(sample(letters[1:3], 20, replace = TRUE)) f fct_expand(f, "d", "e", "f") fct_expand(f, letters[1:6]) fct_expand(f, "Z", after = 0)
Run the code above in your browser using DataLab