Skip to contents

[Stable]

Combine specified old factor Levels in a single new level.

Usage

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

Arguments

x

factor

levels

level names to be combined

new_level

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"))
#> [1] a/b a/b c   d   e  
#> Levels: e d c a/b

combine_levels(x, c("e", "b"))
#> [1] a   e/b c   d   e/b
#> Levels: e/b d c a