[Solved] R – Map one matrix (m.A) to another (m.C) based on P-value in (m.B)


set.seed(1)
options(digits=4)
mA <- matrix(runif(16), 4, 4); mA
      [,1]  [,2]   [,3]  [,4]
[1,] 0.266 0.202 0.6291 0.687
[2,] 0.372 0.898 0.0618 0.384
[3,] 0.573 0.945 0.2060 0.770
[4,] 0.908 0.661 0.1766 0.498

mB <- matrix(runif(16), 4, 4); mB
      [,1]  [,2]   [,3]  [,4]
[1,] 0.718 0.935 0.2672 0.870
[2,] 0.992 0.212 0.3861 0.340
[3,] 0.380 0.652 0.0134 0.482
[4,] 0.777 0.126 0.3824 0.600

mC <- mA
mC[mB>0.05] <- NA; mC

     [,1] [,2]  [,3] [,4]
[1,]   NA   NA    NA   NA
[2,]   NA   NA    NA   NA
[3,]   NA   NA 0.206   NA
[4,]   NA   NA    NA   NA

1

solved R – Map one matrix (m.A) to another (m.C) based on P-value in (m.B)