assertr (version 3.0.1)

has_all_names: Returns TRUE if data.frame or list has specified names

Description

This function checks parent frame environment for existence of names. This is meant to be used with `assertr`'s `verify` function to check for the existence of specific column names in a `data.frame` that is piped to `verify`. It can also work on a non-`data.frame` list.

Usage

has_all_names(...)

Value

TRUE if all names exist, FALSE if not

Arguments

...

A arbitrary amount of quoted names to check for

See Also

exists

Other Name verification: has_only_names()

Examples

Run this code

verify(mtcars, has_all_names("mpg", "wt", "qsec"))

library(magrittr)   # for pipe operator

if (FALSE) {
mtcars %>%
  verify(has_all_names("mpgg"))  # fails
}

mpgg <- "something"

mtcars %>%
  verify(exists("mpgg"))   # passes but big mistake

if (FALSE) {
mtcars %>%
  verify(has_all_names("mpgg")) # correctly fails
}

Run the code above in your browser using DataLab