This question is quite similar to the one asked here: Element-wise mean of several big.matrix objects in R.
However, now I aim to calculate the element-wise mean of 18 filebacked big.matrix objects (each > 4GB) taking into account that na.rm = TRUE.
For normal sized matrices I would do the following:
#Generate a list of 3 example matrices
my.list <- list(matrix(c(1:9), nrow = 3),
matrix(c(10:18), nrow = 3),
matrix(c(19:27), nrow = 3))
my.list[[1]][1,1] <- NA
my.list[[3]][2,1] <- NA
#Take element-wise mean with na.rm = TRUE
test <- apply(simplify2array(my.list), 1:2, mean, na.rm= TRUE)
#This results in:
> test
[,1] [,2] [,3]
[1,] 14.5 13 16
[2,] 6.5 14 17
[3,] 12.0 15 18
I'm using a 64x Windows10 machine with 16GB of RAM.
Any suggestions are very welcome. Thanks!