Open edward-burn opened 1 month ago
We could also include here, or as a separate function, the opposite - when we want specific variables to exist (e.g if the user gives a variable name that they want to stratify by)
x <- dplyr::tibble(a = 1, b = 1, x = 1)
x <- validateExitingColumn(x, "z") # both x would be identical
x <- validateExitingColumn(x, "a") # that would return a warning + remove the column a
When functions create new variables we often need to check whether the variable already exists and warn that it will be overwritten. A utility function that by default 1) produces a warning that the variable exists and 2) drops the existing variable (to avoid any possible problems with joins etc). We could also include the option that instead of warning + drop, instead an error is returned
https://pharmaverse.github.io/admiraldev/dev/reference/warn_if_vars_exist.html