Skip to contents

Warn if a variable already exists inside a dataset

Usage

warn_if_vars_exist(dataset, vars)

Arguments

dataset

A data.frame

vars

character vector of columns to check for in dataset

Value

No return value, called for side effects

See also

Function that provide users with custom warnings suppress_warning(), warn_if_incomplete_dtc(), warn_if_inconsistent_list(), warn_if_invalid_dtc()

Examples

library(dplyr, warn.conflicts = FALSE)
dm <- tribble(
  ~USUBJID,           ~ARM,
  "01-701-1015", "Placebo",
  "01-701-1016", "Placebo",
)

## No warning as `AAGE` doesn't exist in `dm`
warn_if_vars_exist(dm, "AAGE")

## Issues a warning
warn_if_vars_exist(dm, "ARM")
#> Warning: Variable "ARM" already exists in the dataset.