Skip to contents

Small helper function. Checks if all expected columns are in the data frame and if not, adds a column with all missing variables in the data. Thus, the columns will be made explicitly missing in the data frame.

Usage

add_missing_columns(data, columns)

Arguments

data

A data frame.

columns

Expected columns in the data frame.

Value

A data frame with at least all the columns named in columns. The added columns will be of class character.

Examples

if (FALSE) { # \dontrun{
add_missing_columns(head(iris), c("important_column1", "important_column2"))
} # }