Skip to content
Prev 78034 / 398502 Next

is it possible to form matrix of matrices...and multiple arrays

On 9/28/05, booop booop <booopi at yahoo.com> wrote:
Try this:

mat <- list(diag(2), diag(3), diag(4), diag(5))
dim(mat) <- c(2,2)
mat
mat[[1,1]]
Try this. arr is set to a 2x2x2 array filled with diagonal matrices.
Then we set two elements of it to constant matrices.

arr <- lapply(2:9, diag)
dim(arr) <- c(2,2,2)
arr[[1,1,1]]
arr
arr[[1,1,1]] <- matrix(1,2,2)
arr[[1,1,2]] <- matrix(2,2,2)
arr[[1,1,1]]
arr[[1,1,2]]