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 <- ???
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 <- ???
You can set the dim
value of the array like this:
dim(mat.1) <- c(10, 100)
why not just do :
mat.2 = mat
if you avoid overwriting your first matrix, its still in memory just as before. when you operate on an object in R, R creates a copy automatically, so the operation you did on it was actually made on a copy.