[R] How to 'explode' a matrix

Ben Bolker bbolker at gmail.com
Wed Jan 5 19:30:36 CET 2011


Kevin Ummel <kevinummel <at> gmail.com> writes:

> I'm looking for a way to 'explode' a matrix like this:
> 
> > matrix(1:4,2,2)
>      [,1] [,2]
> [1,]    1    3
> [2,]    2    4
> 


  This is the Kronecker product of your matrix with the
matrix  (1 1 ; 1 1)

m <- matrix(1:4,2,2)
kronecker(m,matrix(1,2,2))

  cheers
    Ben Bolker



More information about the R-help mailing list