array2: Make or reshape an array with C-style (row-major) semantics
Description
These functions reshape or make an array using C-style, row-major semantics.
The returned array is still R's native F-style, (meaning, the underlying
vector has been reordered).
Usage
array2(data, dim = length(data), dimnames = NULL)
matrix2(...)
dim2(x) <- value
set_dim2(...)
Arguments
data
what to fill the array with
dim
numeric vector of dimensions
dimnames
a list of dimnames, must be the same length as dims
...
passed on to set_dim()
x
object to set dimensions on (array or atomic vector)
value
a numeric (integerish) vector of new dimensions
Details
Other than the C-style semantics, these functions behave identically to their
counterparts (array2() behaves identically to array(), `dim2<-`()
to `dim<-`()). set_dim2() is just a wrapper around set_dim(..., order = "C").
See examples for a drop-in pure R replacement to reticulate::array_reshape()
# NOT RUN {array(1:4, c(2,2))
array2(1:4, c(2,2))
# for a drop-in replacement to reticulate::array_reshapearray_reshape <- listarrays:::array_reshape
array_reshape(1:4, c(2,2))
# }