has_names: Check whether an object has certain names

Description Usage Arguments Examples

View source: R/assertions.R

Description

Check whether an object has certain names

Usage

1
2
3
has_names(x, which)

x %has_names% which

Arguments

x

object to test

which

name

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
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", ...

## End(Not run)

dynutils documentation built on March 22, 2021, 5:06 p.m.