Description Usage Arguments Details Value See Also Examples
rray_extract()
is the counterpart to rray_yank()
. It extracts elements
from an array by index. It always drops dimensions
(unlike rray_subset()
), and a 1D object is always returned.
1 2 3 4 5 | rray_extract(x, ...) <- value
rray_extract_assign(x, ..., value)
rray_extract(x, ...)
|
x |
A vector, matrix, array, or rray. |
... |
A specification of indices to extract.
|
value |
The value to assign to the location specified by |
Like [[
, rray_extract()
will never keep dimension names.
rray_extract()
works with base R objects as well.
rray_extract()
is similar to the traditional behavior of
x[[i, j, ...]]
, but allows each subscript to have length >1.
A 1D vector of elements extracted from x
.
Other rray subsetters: rray_slice<-
,
rray_subset<-
, rray_yank<-
1 2 3 4 5 6 7 8 9 10 11 | x <- rray(1:16, c(2, 4, 2), dim_names = list(c("r1", "r2"), NULL, NULL))
# Extract the first row and flatten it
rray_extract(x, 1)
# Extract the first row and first two columns
rray_extract(x, 1, 1:2)
# You can assign directly to these elements
rray_extract(x, 1, 1:2) <- NA
x
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.