Hi,

For example, given two 2x2 matrices m1 and m2. I would like to add/subtract
element by element

> m1
         [,1] [,2]
[1,]   NA   NA
[2,]    1    2

> m2
        [,1] [,2]
[1,]    1   NA
[2,]   NA    2

> m1 + m2
        [,1] [,2]
[1,]   NA   NA
[2,]   NA    4

How can I ignore the NA, and get this ? Hope the solution can be extended to
subtract and modulo also.

        [,1] [,2]
[1,]   1   NA
[2,]   1    4

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to