Skip to contents

This function takes a data frame and recodes the factor levels of multiple columns based on the supplied old and new levels. It is designed to be used with dplyr's mutate(across()) function.

Usage

recode_factor_levels(x, old_levels, new_levels)

Arguments

x

A factor vector from a data frame column

old_levels

A character vector of old factor levels

new_levels

A character vector of new factor levels

Value

The factor vector with recoded factor levels