combine_levels: Combine factor levels

View source: R/utils_factor.R

combine_levelsR Documentation

Combine factor levels

Description

[Stable]

Combine specified old factor Levels in a single new level.

Usage

combine_levels(x, levels, new_level = paste(levels, collapse = "/"))

Arguments

x

(factor)
factor variable.

levels

(character)
level names to be combined.

new_level

(string)
name of new level.

Value

A factor with the new levels.

Examples

x <- factor(letters[1:5], levels = letters[5:1])
combine_levels(x, levels = c("a", "b"))

combine_levels(x, c("e", "b"))


tern documentation built on Sept. 24, 2024, 9:06 a.m.