rray_reshape: Reshape an array

Description Usage Arguments Value Examples

View source: R/reshape.R

Description

rray_reshape() is similar to dim()<-. It reshapes x in such a way that the dimensions are different, but the total size of the array is still the same (as measured by rray_elems()).

Usage

1

Arguments

x

A vector, matrix, array or rray.

dim

An integer vector. The dimension to reshape to.

Value

x reshaped to the new dimensions of dim.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- matrix(1:6, ncol = 1)

# Reshape with the same dimensionality
rray_reshape(x, c(2, 3))

# Change the dimensionality and the dimensions
rray_reshape(x, c(3, 2, 1))

# You cannot reshape to a total size that is
# different from the current size.
try(rray_reshape(x, c(6, 2)))

# Note that you can broadcast to these dimensions!
rray_broadcast(x, c(6, 2))

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