Search code examples
rmatrixblock

How to create a matrix from blocks


I have the following blocks:

a = matrix(c(1,3,3,4),nrow=2)
b = c(6,7)
d = 1

I expect joint in a matrix, as the following result:

> new.matrix
     [,1] [,2] [,3]
[1,]    1    3    6
[2,]    3    4    7
[3,]    6    7    1


Solution

  • You can mix rbind and cbind:

    rbind(cbind(a, b), c(b, d))