Small helper function to collapse factors using a Base R syntax
Arguments
- x
a character string or factor
- new_levels
a named list of levels that need to be relabeled. They should be character values. If no names are provided, the first element will be chosen as the factor label.
- warn_non_existent_levels
A logical, whether a warning should be given if levels are not existent.