Reshape (reindex) a multi-dimensional array, using row-major (C-style) reshaping semantics by default.
array_reshape(x, dim, order = c("C", "F"))
x | An array |
---|---|
dim | The new dimensions to be set on the array. |
order | The order in which elements of |
This function differs from e.g. dim(x) <- dim
in a very important way: by
default, array_reshape()
will fill the new dimensions in row-major (C
-style)
ordering, while dim<-()
will fill new dimensions in column-major
(F
ortran-style) ordering. This is done to be consistent with libraries
like NumPy, Keras, and TensorFlow, which default to this sort of ordering when
reshaping arrays. See the examples for why this difference may be important.