Overlap two equally dimension matrices in R

Viewed 23

I have two matrices A and B, both have the same dimensions and are binary in nature. I want to overlap matrix A on matrix B.

Matrix A:

| Gene A   | Gene B |
| -------- | -----------  |
| 0        | 1            |
| 0        | 1            |

Matrix B:

| Gene A   | Gene B |
| -------- | ----------- |
| 1        | 0           |
| 0        | 0           |

Result:
Matrix C:

| Gene A   | Gene B |
| -------- | ----------- |
| 1        | 1           |
| 0        | 1           |

The resultant matrix will also have the same dimension as the input. How can this be done?

Please let me know.

0 Answers
Related