I have a list ( in my real problem ?a double list y[[1:24]][[1:15]] but I
think the solution would be the same)
m <- matrix(1:3, 3, 3)
x <- list(m, m+3, m+6)
?and as I want to have the sum of elements I use Reduce(`+`, x)
having as result
? ? [,1] [,2] [,3]
[1,] ? 12 ? 12 ? 12
[2,] ? 15 ? 15 ? 15
[3,] ? 18 ? 18 ? 18
How can I take the sum of the list elements ignoring NA element
For example if I have
x[[1]][1]<-NA
Then I want to have
? ? [,1] [,2] [,3]
[1,] ?11 ? 12 ? 12
[2,] ? 15 ? 15 ? 15
[3,] ? 18 ? 18 ? 18
instead of