assert_colnames: Assert that a data.frame contains specified column names

Description Usage Arguments Value Examples

View source: R/assert_colnames.R

Description

Given a data.frame or data.table object, assert that all columns in the colnames argument exist as columns.

Usage

1
assert_colnames(data, colnames, only_colnames = TRUE, quiet = FALSE)

Arguments

data

A data.frame or data.table

colnames

Character vector with column names corresponding to columns in data

only_colnames

Assert that the only columns in the data object should be those in colnames. Default = T.

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
assert_colnames(CO2, c("Plant","Type","Treatment","conc","uptake"))
assert_colnames(CO2, c("Plant","Type"), only_colnames=FALSE)

Example output

[1] "All column names present"
[1] "All column names present"

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