append_group: Append Group

View source: R/append_group.R

append_groupR Documentation

Append Group

Description

Creates a new category level by combining existing levels. Appends new observations to dataset.

Usage

append_group(df, group_var, formula, drop = FALSE)

Arguments

df

data.frame or data.table

group_var

unquoted variable name of categorical variable

formula

a formula, LHS ~ RHS. The LHS side denotes the new level label. The RHS denotes the categories to be combined. For example: `Species starting with V` ~ versicolor + verginica.

drop

TRUE/FALSE. If FALSE, the resulting dataframe will include the original data plus observations with the new category level (rows will be duplicated). If TRUE, the command will eliminate rows in the original data with the old category levels (rows are not duplicated). Default is FALSE.

Examples

append_group(iris, `Species starting with V` ~ versicolor + virginica)
append_group(iris, `Species starting with V` ~ versicolor + virginica, drop = TRUE)

thomasgstewart/tgsify documentation built on Oct. 26, 2024, 8:15 p.m.