Skip to contents

Validates that x has all columns listed in required. Aborts with a structured error listing any missing columns.

Usage

check_required_cols(x, required, arg = rlang::caller_arg(x))

Arguments

x

A data frame or tibble.

required

Character vector of required column names.

arg

Argument name for error messages. Defaults to the name of x in the calling frame.

Value

x invisibly.

Examples

df <- data.frame(a = 1, b = 2)
check_required_cols(df, c("a", "b"))