check_names: Check the names of an object contain required names

View source: R/utils.R

check_namesR Documentation

Check the names of an object contain required names

Description

This function checks whether required names are contained within an object. If the object does not contain any/all required names (the precise criteria is controlled by the user), the function returns a helpful error message.

Usage

check_names(
  arg = deparse(substitute(input)),
  input,
  req,
  extract_names = names,
  type = any
)

Arguments

arg

A character string which defines the argument of the parent function.

input

An object for which the names need to be checked.

req

A character vector of required names.

extract_names

A function which is used to extract names from input, such as names or colnames.

type

A function which defines the failure criteria. For example, if type = all, the function will return an error unless all the names in req are contained within input. This is the default. If type = any, the function will return an error only if none of the names in req are contained within input.

Value

If the input fails the check, the function returns a helpful error message. Otherwise, nothing is returned.

Author(s)

Edward Lavender


edwardlavender/Tools4ETS documentation built on Nov. 29, 2022, 7:41 a.m.