| rray_set_dimensions | R Documentation |
rray_set_dimensions() sets the dimensions of x to a new set of dimensions
without changing the total number of elements. Unlike rray_broadcast(),
which repeats elements to fill new dimensions, rray_set_dimensions() simply
reinterprets the existing elements under new dimensions without changing its
size.
rray_set_dimensions(x, dimensions)
x |
An array. |
dimensions |
An integer vector of new dimensions. |
An array with new dimensions but the same size as x.
x <- 1:6
# Set the dimensions to turn a vector into a matrix
rray_set_dimensions(x, c(2L, 3L))
# Set the dimensions to turn a vector into a 3D array
rray_set_dimensions(x, c(3L, 2L, 1L))
# Setting dimensions can't change the size
try(rray_set_dimensions(x, c(6L, 2L)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.