Skip to contents

Compare the column names of a data frame against an expected set of columns and format error messages for missing or unexpected columns.

Usage

check_column(df, expected, slot_name)

Arguments

df

A data frame whose column names are to be validated.

expected

Character vector of expected column names.

slot_name

Character string, the name of the slot or table being validated (used in generated error messages).

Value

Character vector containing error messages describing missing or unexpected columns, or an empty character vector (character(0)) if all columns match expectations.

Details

Computes the set differences between the column names of df and the expected columns. If any expected columns are missing from df, or if any unexpected extra columns are found in df, formatted error messages identifying the slot name slot_name and the affected column names are returned in a character vector.

Author

Frédéric Grelot, frederic.grelot.1994_cran@m4x.org