-
Notifications
You must be signed in to change notification settings - Fork 195
Open
Labels
Description
Since R 3.4.0 utils::hasName() was added as a convient way of testing the existence of a name i.e. the pattern "name" %in% names(x) or for checking the !is.null(x$abc) pattern without partial matching (taken from the docs):
x <- list(abc = 1, def = 2)
!is.null(x$abc) # correct
!is.null(x$a) # this is the wrong test!
hasName(x, "abc")
hasName(x, "a")There is also the basically equivalent rlang::has_name() as a common pattern.