vec_names | R Documentation |
These functions work like rlang::names2()
, names()
and names<-()
,
except that they return or modify the the rowwise names of the vector. These are:
The usual names()
for atomic vectors and lists
The row names for data frames and matrices
The names of the first dimension for arrays
Rowwise names are size consistent: the length of the names always equals
vec_size()
.
vec_names2()
returns the repaired names from a vector, even if it is unnamed.
See vec_as_names()
for details on name repair.
vec_names()
is a bare-bones version that returns NULL
if the vector is
unnamed.
vec_set_names()
sets the names or removes them.
vec_names2(
x,
...,
repair = c("minimal", "unique", "universal", "check_unique", "unique_quiet",
"universal_quiet"),
quiet = FALSE
)
vec_names(x)
vec_set_names(x, names)
x |
A vector with names |
... |
These dots are for future extensions and must be empty. |
repair |
Either a string or a function. If a string, it must be one of
The The options |
quiet |
By default, the user is informed of any renaming
caused by repairing the names. This only concerns unique and
universal repairing. Set Users can silence the name repair messages by setting the
|
names |
A character vector, or |
vec_names2()
returns the names of x
, repaired.
vec_names()
returns the names of x
or NULL
if unnamed.
vec_set_names()
returns x
with names updated.
vec_names2(1:3)
vec_names2(1:3, repair = "unique")
vec_names2(c(a = 1, b = 2))
# `vec_names()` consistently returns the rowwise names of data frames and arrays:
vec_names(data.frame(a = 1, b = 2))
names(data.frame(a = 1, b = 2))
vec_names(mtcars)
names(mtcars)
vec_names(Titanic)
names(Titanic)
vec_set_names(1:3, letters[1:3])
vec_set_names(data.frame(a = 1:3), letters[1:3])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.