Skip to contents

Related to case_if_any() but simpler!

Usage

categorize(variable, ..., sep = ";", ignore_case = TRUE)

Arguments

variable

a character vector

...

dynamic dots, list of recoding

sep

Separator between the results

ignore_case

should match be case-sensitive or not.

Value

A named character vector

Details

It works with the same syntax as forcats::fct_collapse()

Examples

categorize(
c("banana apple", "apple orange pear", "apple", "cucumber"),
 "yellow fruits" = c("banana", "pear"),
 "bad fruits" = c("orange")
)
#> [1] "yellow fruits"            "yellow fruits;bad fruits"
#> [3] ""                         ""