Skip to content

rray_remove_axes() removes axes with a dimension of 1.

Usage

rray_remove_axes(x, axes)

Arguments

x

An array.

axes

The axes to remove, given by position or by title. Each selected axis must have a dimension of 1. At least one axis must remain.

Value

An array with the selected axes removed.

Details

Removed axes lose their names and titles. Surviving axes keep their names and titles and carry them to their new locations.

Examples

x <- array(1:10, c(10, 1, 1))

rray_remove_axes(x, 2)
#>       [,1]
#>  [1,]    1
#>  [2,]    2
#>  [3,]    3
#>  [4,]    4
#>  [5,]    5
#>  [6,]    6
#>  [7,]    7
#>  [8,]    8
#>  [9,]    9
#> [10,]   10
rray_remove_axes(x, c(2, 3))
#>  [1]  1  2  3  4  5  6  7  8  9 10

y <- rray_set_titles(x, c("row", "col", "page"))
rray_remove_axes(y, c("col", "page"))
#>  [1]  1  2  3  4  5  6  7  8  9 10