Description Usage Arguments Author(s) Examples
Drop and slice with controlled dimensionality reduction
1 | drop_selective(x, dim_extract, dim_drop)
|
x |
A multi-dimensional array |
dim_extract |
Which level in 'dim_drop' to extract |
dim_drop |
Index of the dimension to slice and drop. |
Michal Oleszak
1 2 3 4 5 6 7 8 9 | my_array <- array(NA, dim = c(3, 1, 5, 10))
# We want to take the first out of ten levels in the 4th dimension
# and then drop this (and only this) dimension.
my_array[,,,1] %>% dim()
# This reduces the array to two dimensions!
my_array[,,,1, drop = FALSE] %>% dim()
# This keeps all the four dimensions!
drop_selective(my_array, 1, 4) %>% dim()
# Ta-daa!
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.