Functions to get or set the names of an object.
names(x)
names(x) <- value
| Parameter | Description |
|---|---|
x |
an R object. |
value |
a character vector of up to the same length as x, or NULL. |
# NOT RUN {
# print the names attribute of the islands data set
names(islands)
# remove the names attribute
names(islands) <- NULL
islands
rm(islands) # remove the copy made
z <- list(a = 1, b = "c", c = 1:3)
names(z)
# change just the name of the third element.
names(z)[3] <- "c2"
z
z <- 1:3
names(z)
## assign just one name
names(z)[2] <- "b"
z
# }