'cbind()' and 'rbind()' recursively built on cbind2/rbind2
'cbind()' and 'rbind()' recursively built on cbind2/rbind2
The base functions cbind and rbind are defined for an arbitrary number of arguments and hence have the first formal argument .... Now, when S4 objects are found among the arguments, base cbind() and rbind() internally dispatch
recursively, calling cbind2 or rbind2
respectively, where these have methods defined and so should dispatch appropriately.
cbind2() and rbind2() are from the methods package, i.e., standard , and have been provided for binding together two matrices, where in Matrix, we have defined methods for these and the 'Matrix' matrices.
...: for [cr]bind, vector- or matrix-like objects to be bound together; for [cr]bind2, further arguments passed to or from methods; see cbind and cbind2.
deparse.level: integer controlling the construction of labels in the case of non-matrix-like arguments; see cbind.
x, y: vector- or matrix-like objects to be bound together.
Returns
typically a matrix-like object of a similar class as the first argument in ....
Note that sometimes by default, the result is a sparseMatrix if one of the arguments is (even in the case where this is not efficient). In other cases, the result is chosen to be sparse when there are more zero entries is than non-zero ones (as the default sparse in Matrix()).
Author(s)
Martin Maechler
See Also
cbind, cbind2.
Our class definition help pages mentioning cbind2() and rbind2() methods: "denseMatrix", "diagonalMatrix", "indMatrix".
Examples
(a <- matrix(c(2:1,1:2),2,2))(M1 <- cbind(0, rbind(a,7)))# a traditional matrixD <- Diagonal(2)(M2 <- cbind(4, a, D,-1, D,0))# a sparse Matrixstopifnot(validObject(M2), inherits(M2,"sparseMatrix"), dim(M2)== c(2,9))