Validate whether a variable points to a certain exiting column in a table.
Source:R/validate.R
validateColumn.Rd
Validate whether a variable points to a certain exiting column in a table.
Usage
validateColumn(
column,
x,
type = c("character", "date", "logical", "numeric", "integer"),
validation = "error",
call = parent.frame()
)
Examples
x <- dplyr::tibble(a = 1, b = "xxx")
validateColumn("a", x, validation = "warning")
#> [1] "a"
validateColumn("a", x, type = "character", validation = "warning")
#> Warning: ! a type must be a choice of: `character`; but it is numeric.
#> [1] "a"
validateColumn("a", x, type = "numeric", validation = "warning")
#> [1] "a"
validateColumn("not_existing", x, type = "numeric", validation = "warning")
#> Warning: ! not_existing column does not exist.
#> [1] "not_existing"