library(Matrix)
(a <- matrix(c(2:1,1:2), 2,2))
## [,1] [,2]
## [1,] 2 1
## [2,] 1 2
cbind(0, Matrix::rBind(a, 7)) # remains traditional matrix
## Warning: 'rBind' is deprecated.
## Since R version 3.2.0, base's rbind() should work fine with S4 objects
## [,1] [,2] [,3]
## [1,] 0 2 1
## [2,] 0 1 2
## [3,] 0 7 7
D <- Matrix::Diagonal(2)
Matrix::cBind(4, a, D, -1, D, 0) # a sparse Matrix
## Warning: 'cBind' is deprecated.
## Since R version 3.2.0, base's cbind() should work fine with S4 objects
## 2 x 9 sparse Matrix of class "dgCMatrix"
##
## [1,] 4 2 1 1 . -1 1 . .
## [2,] 4 1 2 . 1 -1 . 1 .