assert_coltypes {assertable} | R Documentation |
Given a data.frame or data.table object, assert that all columns in the names of the coltypes argument match the types of the elements of the coltypes argument.
assert_coltypes(data, coltypes, quiet = FALSE)
data |
A data.frame or data.table |
coltypes |
List with names corresponding to columns in data. The types of the columns in data will be tested against types of the elements in coltypes. |
quiet |
Do you want to suppress the printed message when a test is passed? Default = F. |
Throws error if test is violated.
# Should pass
assert_coltypes(CO2, list(Plant = integer(), conc = double()))
# Should fail
## Not run:
assert_coltypes(CO2, list(Plant = character(), conc = character()))
## End(Not run)