check for specified columns and corresponding column types
Source:R/check_for_column.R
check_for_column.Rd
check for specified columns and corresponding column types
Arguments
- d
input dataframe
- column_name
character string defining name of column to be checked
- column
character vector to be checked (e.g., d$column_name)
- column_type
(optional) desired column type to be checked for (e.g., 'character')
Value
if column_name exists in d and is of the correct column_type, nothing is returned. if column_name does not exist in d, an error is thrown. if column is not of the correct column_type, a warning is shown.
Examples
if (FALSE) {
d <- tibble::tribble(
~"id", ~"value",
"123", 123,
"456", 456
)
check_for_column(d, "id", d$id, "double")
check_for_column(d, "id2", d$id2, "double")
}