Hello
I suspect that adiag() of the magic package is what you need:
> library(magic)
Loading required package: abind
Attaching package: 'magic'
The following object(s) are masked from package:mgcv :
magic
> a <- matrix(1:4,2,2)
> b <- matrix(1:9,3,3)
> adiag(a,b)
[
Dear R users, I'm trying to build a diagonal matrix from a group of
matrices. These matrices have been built in a for loop. That is, I've
subsetted a preliminar matrix to obtain a certain number of square
sub-matrices, and now I need to create a diagonal out of these.
Suppose my matrix is a square
2 matches
Mail list logo