setNames | R Documentation |
Improvement to stats::setNames()
sets new names for an object,
ensuring that the length of the new names matches the length of the object.
Additionally, if the length of newNames is one, it is repeated to match
the length of the object.
setNames(object, newNames)
object |
An object. |
newNames |
A character vector specifying the new names. |
The object with updated names.
# Set new names for a vector
x <- c(1, 2, 3)
x <- setNames(x, c("A", "B", "C"))
# some syntactic sugar can be achieved with a special mutator
`%setNames%` <- createMutator(setNames)
x %setNames% c("D", "E", "F")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.