Learn R Programming

ABCDscores (version 6.1.0)

check_col_names: 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)

Value

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

Arguments

data

tbl. Data frame to check for the column name.

names

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

Examples

Run this code
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"))
})

Run the code above in your browser using DataLab