combine_levels {tern}R 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"))


[Package tern version 0.9.5 Index]