Description Usage Arguments Details Value Author(s) See Also Examples

The base functions `cbind`

and `rbind`

are
defined for an arbitrary number of arguments and hence have the first
formal argument `...`

. For that reason, in the past S4 methods
could easily be defined for binding together matrices inheriting from
`Matrix`

.

For that reason, `cbind2`

and `rbind2`

have
been provided for binding together *two* matrices, and we have
defined methods for these and the `'Matrix'`

-matrices.

Before **R** version 3.2.0 (April 2015), we have needed a substitute for
*S4-enabled* versions of `cbind`

and `rbind`

, and
provided `cBind`

and `rBind`

with identical syntax and
semantic in order to bind together multiple matrices (`"matrix"`

or `"Matrix"`

and vectors.
With **R** version 3.2.0 and newer, `cBind`

and `rBind`

are
*deprecated* and produce a deprecation warning (via
`.Deprecated`

), and your code should start using
`cbind()`

and `rbind()`

instead.

1 2 |

`...` |
matrix-like |

`deparse.level` |
integer determining under which circumstances
column and row names are built from the actual arguments'
‘expression’, see |

The implementation of these is *recursive*, calling
`cbind2`

or
`rbind2`

respectively, where these have methods
defined and so should dispatch appropriately.

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()`

).

Martin Maechler

`cbind2`

, `cbind`

,
Documentation in base **R**'s methods package
.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ```
(a <- matrix(c(2:1,1:2), 2,2))
D <- Diagonal(2)
if(getRversion() < "3.2.0") {
M1 <- cbind(0, rBind(a, 7))
print(M1) # remains traditional matrix
M2 <- cBind(4, a, D, -1, D, 0) # a sparse Matrix
print(M2)
} else { ## newer versions of R do not need cBind / rBind:
M1 <- cbind(0, suppressWarnings(rBind(a, 7)))
print(M1) # remains traditional matrix
M2 <- suppressWarnings(cBind(4, a, D, -1, D, 0)) # a sparse Matrix
print(M2)
stopifnot(identical(M1, cbind(0, rbind(a, 7))),
identical(M2, cbind(4, a, D, -1, D, 0)))
}# R >= 3.2.0
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.