Learn R Programming

traumar (version 1.2.4)

validate_names: Validate Column Names

Description

This function checks if all column names of a data frame or tibble are within a specified set of valid values. Depending on the specified type, it will either throw an error, issue a warning, or send a message.

Usage

validate_names(
  input,
  check_names,
  type = c("error", "warning", "message"),
  na_ok = TRUE,
  null_ok = TRUE,
  var_name = NULL,
  calls = NULL
)

Value

NULL. The function is used for its side effects.

Arguments

input

A data.frame or tibble. validate_names() will run colnames(input) to get the expected column names.

check_names

A vector of column names as strings to check against input.

type

A character string specifying the type of message to be displayed if the input is not numeric or if the values are out of range. Must be one of "error", "warning", or "message".

na_ok

Logical. If TRUE, NA values are allowed. Default is TRUE.

null_ok

Logical. If TRUE, NULL values are allowed. Default is TRUE.

var_name

Optional. A character string giving the desired variable (or object) name that will appear in console output in place of the how the object will typically be named in messages via deparse(substitute(input)).

calls

Optional. The number of callers to go back in the call stack for error messaging. If NULL, will default to 2.

Author

Nicolas Foss, Ed.D., MS