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()
).
rray_reshape(x, dim)
x | A vector, matrix, array or rray. |
---|---|
dim | An integer vector. The dimension to reshape to. |
x
reshaped to the new dimensions of dim
.
#> [,1] [,2] [,3] #> [1,] 1 3 5 #> [2,] 2 4 6#> , , 1 #> #> [,1] [,2] #> [1,] 1 4 #> [2,] 2 5 #> [3,] 3 6 #># You cannot reshape to a total size that is # different from the current size. try(rray_reshape(x, c(6, 2)))#> Error : The size you are reshaping from (6) must be equal to the size you are reshaping to (12).#> [,1] [,2] #> [1,] 1 1 #> [2,] 2 2 #> [3,] 3 3 #> [4,] 4 4 #> [5,] 5 5 #> [6,] 6 6