Learn R Programming

assertr (version 3.0.1)

has_class: Returns TRUE if data.frame columns have a specified class

Description

This is meant to be used with `assertr`'s `verify` function to check for the existence of a specific column class in a `data.frame` that is piped to `verify`.

Usage

has_class(..., class)

Value

TRUE if all classes are correct, FALSE if not

Arguments

...

An arbitrary amount of quoted column names to check for

class

Expected class for chosen columns.

Examples

Run this code

verify(mtcars, has_class("mpg", "wt", class = "numeric"))

library(magrittr)   # for pipe operator

if (FALSE) {
mtcars %>%
  verify(has_class("mpg", class = "character"))  # fails
}

Run the code above in your browser using DataLab