You can use the abind package and then use do.call(abind, c(test, along = 3))
library(abind) testArray <- do.call(abind, c(test, along = 3))
Or you can use simplify = 'array' in a sapply call, instead of lapply ). simplify = 'array' does not match simplify = TRUE , as it will change the higher argument to simplify2array
eg,
foo <- function(x) matrix(1:10, ncol = 5) # the default is simplify = TRUE sapply(1:5, foo) [,1] [,2] [,3] [,4] [,5] [1,] 1 1 1 1 1 [2,] 2 2 2 2 2 [3,] 3 3 3 3 3 [4,] 4 4 4 4 4 [5,] 5 5 5 5 5 [6,] 6 6 6 6 6 [7,] 7 7 7 7 7 [8,] 8 8 8 8 8 [9,] 9 9 9 9 9 [10,] 10 10 10 10 10 # which is *not* what you want # so set `simplify = 'array' sapply(1:5, foo, simplify = 'array') , , 1 [,1] [,2] [,3] [,4] [,5] [1,] 1 3 5 7 9 [2,] 2 4 6 8 10 , , 2 [,1] [,2] [,3] [,4] [,5] [1,] 1 3 5 7 9 [2,] 2 4 6 8 10 , , 3 [,1] [,2] [,3] [,4] [,5] [1,] 1 3 5 7 9 [2,] 2 4 6 8 10 , , 4 [,1] [,2] [,3] [,4] [,5] [1,] 1 3 5 7 9 [2,] 2 4 6 8 10 , , 5 [,1] [,2] [,3] [,4] [,5] [1,] 1 3 5 7 9 [2,] 2 4 6 8 10