assert_coltypes {assertable}R Documentation

Assert that a data.frame's columns are certain types

Description

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.

Usage

assert_coltypes(data, coltypes, quiet = FALSE)

Arguments

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.

Value

Throws error if test is violated.

Examples

# 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)

[Package assertable version 0.2.8 Index]