check_col_names: Check if a column name already exists in a data frame

check_col_namesR Documentation

Check if a column name already exists in a data frame

Description

This function checks if a column name already exists in a data frame. If the column name already exists, the function will abort with an error.

Usage

check_col_names(data, names)

Arguments

data

tbl. Data frame to check for the column name.

names

character vector, The name(s) of the column to check for.

Value

NULL. The function will abort with an error if the column name already exists.

Examples

data <- tibble::tibble(a = NA, b = NA, c = NA)
try({
  check_col_names(data, c("a", "b", "c"))
  check_col_names(data, c("a", "d"))
})

ABCDscores documentation built on Sept. 11, 2025, 5:08 p.m.