Stable lifecycle

This names getter always returns a character vector, even when an object does not have a names attribute. In this case, it returns a vector of empty names "". It also standardises missing names to "".

names2(x)

Arguments

x

A vector.

Life cycle

names2() is stable.

Examples

names2(letters)
#>  [1] "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
#> [26] ""

# It also takes care of standardising missing names:
x <- set_names(1:3, c("a", NA, "b"))
names2(x)
#> [1] "a" ""  "b"