R: add matrices based on row and column names
问题 I have two matrices I want to sum based on their row and column names. The matrices will not necessarily have all rows and columns in common - some may be missing from either matrix. For example, consider two matrices A and B: A= B= a b c d a c d e v 1 1 1 0 v 0 0 0 1 w 1 1 0 1 w 0 0 1 0 x 1 0 1 1 y 0 1 0 0 y 0 1 1 1 z 1 0 0 0 Column e is missing from matrix A and column b is missing from matrix B. Row z is missing from matrix A and row x is missing from matrix B. The summed table I'm looking