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