Examples for 'stats::setNames'


Set the Names in an Object

Aliases: setNames

Keywords: list

### ** Examples

setNames( 1:3, c("foo", "bar", "baz") )
foo bar baz 
  1   2   3 
# this is just a short form of
tmp <- 1:3
names(tmp) <-  c("foo", "bar", "baz")
tmp
foo bar baz 
  1   2   3 
## special case of character vector, using default
setNames(nm = c("First", "2nd"))
  First     2nd 
"First"   "2nd" 

[Package stats version 4.2.3 Index]