Learn R Programming

climatehealth (version 1.0.0)

abort_column_not_found: Raise a column-not-found error with available columns

Description

Use this when a required column is missing from a dataset. Includes fuzzy matching to suggest the closest available column name.

Usage

abort_column_not_found(
  column,
  available,
  dataset_name = "dataset",
  call = rlang::caller_env()
)

Value

Never returns; always raises an error.

Arguments

column

The column name that was not found

available

Character vector of available column names

dataset_name

Optional name of the dataset for clearer messages

call

The call to include in the error

Examples

Run this code
# \donttest{
data <- data.frame(temp = 1)
if (!("tmean" %in% colnames(data))) {
  err <- tryCatch(
    abort_column_not_found("tmean", colnames(data)),
    error = identity
  )
  err$suggestion
}
# }

Run the code above in your browser using DataLab