I have the following list of matrices, one of which has the matrix na
l <- list(structure(c(-0.345207968896003, -0.106294281751886,
-0.106294281751886, -0.0327278202985066), .Dim = c(2L, 2L),
.Dimnames = list(c("cst", "HHI"), c("cst", "HHI"))),
structure(c(1.15139745442976e-05, 3.68766982139475e-06,
3.68766982139475e-06, 1.15176322872764e-06 ), .Dim = c(2L, 2L),
.Dimnames = list(c("cst", "HHI"), c("cst", "HHI"))),
structure(c(NaN, NaN, NaN, NaN), .Dim = c(2L, 2L), .Dimnames = list(
c("cst", "HHI"), c("cst", "HHI"))),
structure(c(-7.27547318293674e-83, -2.19548052580106e-83,
-2.19548052580106e-83, -7.02352060565763e-84 ), .Dim = c(2L, 2L),
.Dimnames = list(c("cst", "HHI"), c("cst", "HHI"))),
structure(c(4.87470592316947e-170, 1.84511037510365e-170,
1.84511037510365e-170, 6.6824969949533e-171), .Dim = c(2L, 2L ),
.Dimnames = list(c("cst", "HHI"), c("cst", "HHI"))), structure(c(0,
0, 0, 0), .Dim = c(2L, 2L), .Dimnames = list(c("cst", "HHI"),
c("cst", "HHI"))))
and I would like to summarize all matrices using Reduce.
a <-Reduce('+',l)
How can I sum matrices removing NaNs?