reshape | R Documentation |
Reshapes a matrix according to a certain number of dimensions
reshape(A, sz)
A |
input matrix |
sz |
vector containing the dimensions of the output vector |
This function replicates the functionality of the reshape()
function on Matlab. This function is basically a fancy wrapper for the
array()
function in R, but is useful because it saves the user translation
time. Moreover, it introduces validation code that alter the behavior of
array()
and makes it more similar to replicate()
.
the input matrix, reshaped according to the vector sz
The Matlab function also accepts as input the dismemberment of sz as scalars.
mx <- matrix(1:4, 2) ra <- array(1:12, c(2, 3, 2)) mx reshape(mx, c(1, 4)) ra reshape(ra, c(3, 2, 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.