required_cols.Rd
This utility function checks whether all expected columns are present in a given data frame. It is particularly useful for validating user input or internal data structures within a package, helping to prevent downstream errors caused by missing variables.
required_cols(df, expected, name)
The function does not return anything. It throws an error if required columns are missing.
required_cols(data.frame(a = 1, b = 2), c("a", "b"), "example_df") # OK
if (FALSE) { # \dontrun{
required_cols(data.frame(a = 1), c("a", "b"), "example_df") # Error
} # }