setNames
Attach a names attribute to an object
Description
Returns the input object with a new names attributes.
Usage
setNames(object = nm, nm)
Arguments
object |
any object that accepts a names attribute; a vector of any type.
|
nm |
a vector of character strings or an object that can be coerced to a
vector of character strings. The length must be less than or equal to
the length of object. If you specify NULL, the function
deletes the names attribute of object.
|
Details
setNames(x, nm) performs the same action as names(x) <-
nm except that setNames returns the modification of x
but does not modify x.
Value
returns an object with the newly assigned names attribute.
See Also
Examples
setNames(1:3, c("one", "two", "three"))
setNames(nm = 1:5)