View source: R/check_named_vctr.R
| check_named_vctr | R Documentation |
This function checks whether named lists and vectors contain
invalid values (like NULL or NA), have invalid names (such as missing
or empty names), ensures the number of valid names matches the number of
supplied values, and confirms that valid names from the object correspond
to the provided names. If any of these checks fail, the function returns
the default value.
check_named_vctr(x, names, default)
x |
A named vector. |
names |
A character vector or list of character vectors of length one specifying the names to be matched. |
default |
Default value to return |
Either the original object, x, or the default value.
Ama Nyame-Mensah
# returns NULL
check_named_vctr(x = c(one = 1, two = 2, 3),
names = c("one", "two", "three"),
default = NULL)
# returns x
check_named_vctr(x = list(one = 1, two = 2, three = 3),
names = list("one", "two", "three"),
default = NULL)
# also returns x
check_named_vctr(x = c(baako = 1, mmienu = 2, mmiensa = 3),
names = list("baako", "mmienu", "mmiensa"),
default = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.