powered by
Remove/reorder levels
refactor(x, levs = levels(x), repl = NA)
Character or Factor
Set of levels to use
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'
# NOT RUN { refactor(diamonds$cut, c("Premium","Ideal")) %>% head() refactor(diamonds$cut, c("Premium","Ideal"), "Other") %>% head() # }
Run the code above in your browser using DataLab