I have several matrices, each having different row numbers and names, but same column names. I want to combine these matrices. For example I have matrix m1 as
m1 = round(matrix(c(rnorm(18,5,1)), nrow = 6, ncol = 3), digits = 0)
rownames(m1)<- c(LETTERS[1:5], "J")
colnames(m1) <- c(letters[1:3])
> m1
a b c
A 3 7 6
B 4 5 5
C 6 6 6
D 5 4 5
E 4 7 6
J 5 5 4
and second matrix:
m2 = round(matrix(c(rnorm(6, mean = 2)), nrow = 3, ncol = 2), digits = 0)
rownames(m2)<-c("A", "c", "J")
colnames(m2) <- c(letters[1:2])
m2
a b
A 1 0
c 3 2
J 1 3
and I want output like this:
a b c a b
A 3 7 6 1 0
B 4 5 5
C 6 6 6 3 2
D 5 4 5
E 4 7 6
J 5 5 4 1 3
How to do it in R?