rray_squeeze: Squeeze an rray

Description Usage Arguments Details Value Examples

View source: R/squeeze.R

Description

rray_squeeze() is conceptually similar to base::drop(), but it allows for the specification of specific dimensions to squeeze.

Usage

1
rray_squeeze(x, axes = NULL)

Arguments

x

A vector, matrix, array or rray.

axes

An integer vector specifying the size 1 dimensions to drop. If NULL, all size 1 dimensions are dropped.

Details

The dimension name handling of rray_squeeze() is essentially identical to drop(), but some explanation is always helpful:

Value

x with the axes dropped, if possible.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# (10, 1) -> (10)
x <- rray(1:10, c(10, 1))
rray_squeeze(x)

# Multiple squeezed dimensions
# (10, 1, 1) -> (10)
y <- rray_reshape(x, c(10, 1, 1))
rray_squeeze(y)

# Use `axes` to specify dimensions to drop
# (10, 1, 1) -> drop 2 -> (10, 1)
rray_squeeze(y, axes = 2)

# Dimension names are kept here
# (10, 1) -> (10)
x <- rray_set_row_names(x, letters[1:10])
rray_squeeze(x)

# And they are kept here
# (1, 10) -> (10)
rray_squeeze(t(x))

rray documentation built on July 23, 2019, 5:04 p.m.