Check a named vector
check_named_vctr.Rd
This function assesses whether named lists and vectors have
invalid values (like NULL
or NA
), invalid names (such as missing or
empty names), confirms that the count of valid names matches the count of
provided values, and verifies that the valid names obtained from the named
object align with the supplied names. If any checks fail, the default
value is returned.
Examples
# returns NULL
check_named_vctr(x = c(one = 1, two = 2, 3),
names = c("one", "two", "three"),
default = NULL)
#> NULL
# returns x
check_named_vctr(x = list(one = 1, two = 2, three = 3),
names = list("one", "two", "three"),
default = NULL)
#> $one
#> [1] 1
#>
#> $two
#> [1] 2
#>
#> $three
#> [1] 3
#>
# also returns x
check_named_vctr(x = c(baako = 1, mmienu = 2, mmiensa = 3),
names = list("baako", "mmienu", "mmiensa"),
default = NULL)
#> baako mmienu mmiensa
#> 1 2 3