dimlabels<- {str2str} | R Documentation |
Add Elements to Vectors
Description
`dimlabels<-`
adds elements to vectors as a side effect. The purpose of
the function is to replace names(dimnames(x))
with a single function call.
Usage
dimlabels(x) <- value
Arguments
x |
array or any object with dimnames. The object may or may not already have dimlabels. |
value |
character vector of dimlabels to be added to |
Value
Like other similar functions (e.g., `names<-`
and `[<-`
),
it does not appear to have a return object. However, it technically does as a
side effect. The argument x
will have been changed such that value
has been added as dimlabels. If a traditional return object is desired, and no side
effects, then it can be called like a traditional function:
obj2 <- 'dimlabels<-'(x = obj, value = dimlab).
Examples
a <- array(c(letters, NA), dim = c(3,3,3),
dimnames = replicate(3, expr = 1:3, simplify = FALSE))
dimlabels(a) <- c("first","second","third")
dimlabels(a)[[2]] <- c("2nd")
dimlabels(a)[c(1,3)] <- c("1st","3rd")
print(a)