assert_colnames {assertable}R Documentation

Assert that a data.frame contains specified column names

Description

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

Usage

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

assert_colnames(CO2, c("Plant","Type","Treatment","conc","uptake"))
assert_colnames(CO2, c("Plant","Type"), only_colnames=FALSE)

[Package assertable version 0.2.8 Index]