has_all_items: Does a df grouping column have all possible instances?

View source: R/has_all_items.R

has_all_itemsR Documentation

Does a df grouping column have all possible instances?

Description

check that a data frame has all of the specified items in the specified column. if it does not have those items, add them. Also has functionality to alter the added rows.

Usage

has_all_items(df, column, col_items, cols_to_modify = NULL)

Arguments

df

data frame to check

column

column that should have all of the items specified in col_items

col_items

items that should be present in col_items

cols_to_modify

named list of columns that should be modified, where list names correspond to column names and values correspond to new values that should be in the added rows

Value

a df

Examples

df <- data.frame(groups = letters[1:5], value = rnorm(5))
has_all_items(df, groups, letters[1:10], list(value = 0))


chris-s-friedman/Friedman documentation built on Feb. 12, 2023, 8:02 p.m.