drop_selective: Drop and slice with controlled dimensionality reduction

Description Usage Arguments Author(s) Examples

Description

Drop and slice with controlled dimensionality reduction

Usage

1
drop_selective(x, dim_extract, dim_drop)

Arguments

x

A multi-dimensional array

dim_extract

Which level in 'dim_drop' to extract

dim_drop

Index of the dimension to slice and drop.

Author(s)

Michal Oleszak

Examples

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!

MichalOleszak/momisc documentation built on May 29, 2019, 3:02 a.m.