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

Description Usage Arguments Value Examples

View source: R/assert_coltypes.R

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

1
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

1
2
3
4
5
6
7
# 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)

assertable documentation built on Jan. 27, 2021, 9:07 a.m.