Learn R Programming

dynutils (version 1.0.11)

has_names: Check whether an object has certain names

Description

Check whether an object has certain names

Usage

has_names(x, which)

x %has_names% which

Arguments

x

object to test

which

name

Examples

Run this code
if (FALSE) {
library(assertthat)
li <- list(a = 1, b = 2)

assert_that(li %has_names% "a")
# TRUE

assert_that(li %has_names% "c")
# Error: li is missing 1 name from "c": "c"

assert_that(li %has_names% letters)
# Error: li is missing 24 names from letters: "c", "d", "e", ...
}

Run the code above in your browser using DataLab