blockdiag | R Documentation |
Construct a block-diagonal matrix from a list of submatrices.
blockdiag(...)
... |
a comma-separated list of matrix objects that will form the submatrices of the block-diagonal matrix. |
A block-diagonal matrix with dimensions equal to the sum of the dimensions of the submatrices.
If you want to use a previously constructed list of matrices,
use do.call
(see the examples).
Doesn't preserve names or attributes (yet).
Ben Bolker
m1 <- matrix(1,nrow=2,ncol=2)
m2 <- matrix(2,nrow=1,ncol=3)
m3 <- matrix(3,nrow=3,ncol=2)
blockdiag(m1,m2,m3)
l <- list(m1,m2,m3)
do.call("blockdiag",l)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.