Dear all, Suppose that I have a matrix A A <- matrix(c(3,3,3,3,3,3,3,3,3),3,3) and a logical matrix B B <- matrix(c(T,T,T,F,T,T,F,T,F),3,3) The result matrix should be C <- matrix(c(3,3,3,NA,3,3,NA,3,NA),3,3) Is there any simple tip or trick to perform this without looping? Thanks in advance for any suggestion. Best regards, Andrej