Skip to content
Prev 257745 / 398502 Next

applying a function over a matrix 2N x M to produce a matrix N x M

On Apr 22, 2011, at 12:13 PM, Christine SINOQUET wrote:

            
> mat[seq(1, nrow(mat), by=2), ]+mat[seq(2, nrow(mat), by=2), ]
      [,1] [,2] [,3] [,4] [,5] [,6]
[1,]    1    1    1    1    1    0
[2,]    1    2    2    0    1    1
[3,]    1    1    0    2    0    1
David Winsemius, MD
West Hartford, CT