df_add_category: Add category for column.

View source: R/df_add_category.R

df_add_categoryR Documentation

Add category for column.

Description

Add category for column.

Usage

df_add_category(x, col, values, new.value, factor.handling = "keep")

Arguments

x

[data.frame]
Data frame with at least one row and column.

col

[integer | string]
Column number or colmumn name.

values

[character]
Which values of the column col shall be unioned into the new category.

new.value

[any]
New category value.

factor.handling

[string]
Determines how to handle the case that col is a factor column. Option “drop” converts the factor into a character column. Option “keep” does the same, but after adding the new category, the factor property is reestablished. If the factor was ordered, the new category is placed last.

Value

Modified data frame.

See Also

Other data frame helpers: df_add_constant_columns(), df_explode(), df_rows_to_list(), df_split_col()


jakobbossek/re documentation built on Nov. 15, 2024, 1:42 a.m.