array_reshape | R Documentation |
Reshape one dimension of a multidimensional array. Use this to say that some dimension (say with length 20) actually represents a number of other dimensions (e.g., 2 x 10 or 2 x 2 x 5). This might be the case if you've been doing a simulation with a large number of parameter sets that are pooled over some other grouping factors (e.g., in a sensitivity analysis)
array_reshape(x, i, d)
x |
An array |
i |
The index of the dimension to expand |
d |
The new dimensions for data in the i'th dimension of x |
A multidimensional array
array_flatten which undoes this operation
# Suppose we had a 4 x 6 array of data:
m <- matrix(1:24, 4, 6)
# And suppose that the second dimension really represented a 2 x 3
# matrix; so that looking at one copy of the 2nd dimension we see
m[1, ]
# But instead we might want to see
res <- mcstate::array_reshape(m, 2, c(2, 3))
res[1, , ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.