names
attribute of an object, usually a list
or a vector.
names(x) names(x) <- value
x
.
x
has a
names
attribute, this attribute
is returned; otherwise, it returns
NULL
.
The
names
attribute can be used for subset and
element selection.
It is a character vector the same length as
x
.
names
attribute of
x
is set
to
value
, which must have the same length as
x
.
To explicitly delete the
names
attribute,
use
names(x) <- NULL
.
A
names
attribute cannot be added to a matrix or array, as these structures store names in a
dimnames
attribute. If
x
is a matrix with a single column, then
value
is used as the row names. If
x
is an array with a single dimension,
value
is used as the names of the first dimension. Otherwise, the assignment stops with an error when
x
is a matrix or array.
You should not remove names from a data frame; this would create an illegal data frame, and some operations will fail.
Use
""
in
value
for the objects in
x
that do not have names.
A
bdVector
does not contain names, so
names(x)
always returns
NULL
,
and
names(x) <- value
does nothing.
The
value
may be a character vector, or anything that
can be coerced to a character vector. However, it should not
be a
bdCharacter
or other
bdVector
;
you can convert these to an ordinary vector using
bd.coerce
Instead of using
names
to replace row names from a matrix,
use
rowIds
or
dimnames
.
See
as.name
for objects of mode
"name"
.
x.name <- x[names(x)!=""] # find the elements of x with non-null names ozone.xy[["x"]] # alternative to ozone.xy$x