Hi, I'm reasonably certain that each entry of dimnames must be of length no greater than the corresponding entry of dim. With that in mind, can you do what you need to do with a list of matrices?
# 3x3x2 array
array(
1:18,
dim = c(3, 3, 2),
dimnames = list(
c("r1", "r2", "r3"),
c("c1", "c2", "c3"),
c("matrix1", "matrix2")
)
)
# list of 3x3 matrices
list(
matrix1 = matrix(1:9, nrow = 3, dimnames = list(c("r1", "r2", "r3"), c("c1", "c2", "c3"))),
matrix2 = matrix(10:18, nrow = 3, dimnames = list(c("r4", "r5", "r6"), c("c4", "c5", "c6")))
)
I just used the vector 1:18 as data because I don't know what vector1, vector2, vector3, and vector4 were in your code (I can infer it from the output, but that's a bit hard for me to do).