Functions to get or set the names of an object.
## S4 method for signature 'FolderClass' names(x)
an R object.
names is a generic accessor function, and
names<- is a
generic replacement function. The default methods get and set
"names" attribute of a vector (including a list) or
the names of the corresponding list, i.e.,
names(as.list(env, all.names = TRUE)) which are also given by
ls(env, all.names = TRUE, sorted = FALSE). If the
environment is used as a hash table,
names(env) are its
value is shorter than
x, it is extended by character
NAs to the length of
It is possible to update just part of the names attribute via the
general rules: see the examples. This works because the expression
there is evaluated as
z <- "names<-"(z, "[<-"(names(z), 3, "c2")).
"" is special: it is used to indicate that there is no
name associated with an element of a (atomic or generic) vector.
"" will match nothing (not even elements which
have no name).
A name can be character
NA, but such a name will never be
matched and is likely to lead to confusion.
Both are primitive functions.
NULL or a character vector of the same length
NULL is given if the object has no names,
including for objects of types which cannot have names.) For an
environment, the length is the number of objects in the environment
but the order of the names is arbitrary.
names<-, the updated object. (Note that the value of
names(x) <- value is that of the assignment,
the return value from the left-hand side.)
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# 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) <- "c2" z z <- 1:3 names(z) ## assign just one name names(z) <- "b" z
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.