Search code examples
rarraysmatrixreshapereticulate

R - undo an array_arrange()


I am after a way to undo the array_reshape() function in R. Any help is welcomed.

library(reticulate) 

mat <- matrix(rep(1:1000), nrow = 10)

mat.1 <- array_reshape(mat, c(nrow(mat), 10,10,1)) 

# make mat.2 the same dimensions as mat
mat.2 <- ???

Solution

  • You can set the dim value of the array like this:

    dim(mat.1) <- c(10, 100)