Description Usage Arguments Value See Also Examples
Slices array by specified dimension.
1 | slice(x, MARGIN, n)
|
x |
An array-like object. |
MARGIN |
An integer giving the dimension to slice by. |
n |
Number of slice. |
Returns array of dimensions dim(x)[-MARGIN]
. The corresponding
dimnames are preserved.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | x <- 1:10
slice(x, 1, 1)
x <- matrix(1:4, 2, 2)
rownames(x) <- c("Row 1", "Row 2")
colnames(x) <- c("Col 1", "Col 2")
x
slice(x, 1, 1)
slice(x, 1, 2)
slice(x, 2, 1)
slice(x, 2, 2)
x <- array(1:24, dim = c(2, 3, 4))
dimnames(x) <- list(letters[1:2], letters[3:5], letters[6:9])
x
slice(x, 1, 1)
slice(x, 2, 1)
slice(x, 3, 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.