match_to_groups: Match elements to groups

View source: R/utils.R

match_to_groupsR Documentation

Match elements to groups

Description

Match elements to groups

Usage

match_to_groups(subset, groups, replace_nas = "Other", strict_dups = FALSE)

Arguments

subset

vector of elements

groups

list of groups

replace_nas

how to handle elements that don't appear in any of the groups. If a string is provided, it uses it as a new group for these elements.

strict_dups

how to handle elements that appear in multiple groups. By default, the first matching group is reported and a warning is issued. If TRUE, it raises an error.

It returns the name of the group where each element in the subset appears. If not in any group, it combines them into the "other " group (intentional space, in case "other" exists)


nachocab/clickme documentation built on Nov. 11, 2023, 3:14 p.m.