slice.tensor {tensorA} | R Documentation |
Working with the indices of a tensor (accessing, slicing, renaming, ...)
Description
Indexing of tensors allows beside the ordinary selection of ranges of indices the renaming of indices. The functions are mainly here to keep the the tensor property of the results.
Usage
slice.tensor(X,i,what,drop=FALSE)
## Methods for class tensor
# X[...,drop=TRUE]
# X[...,drop=TRUE] <- value
# X[[...,drop=TRUE]]
# X[[...,drop=TRUE]] <- value
Arguments
X |
A tensor |
i |
an index given as number or character |
what |
levels of the index, a number or a character from dimnames |
drop |
a boolean, if true, indices with only a single level are removed |
... |
arguments of the form |
Details
The functions allow to rename dimensions and to take select a part of the tensor.
Value
a new tensor with dimensions renamed or individual levels selected
Author(s)
K. Gerald van den Boogaart
See Also
Examples
A <- to.tensor(1:20,c(A=2,B=2,C=5))
A[C=1]
A[C=1:3]
A[[B=~b]] # renaming dimensions
A[[B=~b,A=~aaa]]
A[[B=~b,A=~aaa,aaa=1]]
A[[A=1,B=~gamma]][C=1:2]
A