This is a test version of Biostars. For the public version, visit https://www.biostars.org.
all combinations of matrix addition

hi,

i have a matrix that i want to transform by adding rows that represent the addition of pairs of rows on the matrix. ie, if the matrix is:

0,0,1,1,0,0 0,1,0,0,0,0 0,0,1,0,0,0

the output would be a 6x6 matrix such as

0,0,1,1,0,0 0,1,0,0,0,0 0,0,1,0,0,0 0,1,1,1,0,0 # rows 1+2 0,0,2,1,0,0 # rows 1+3 0,1,1,0,0,0 # rows 2+3

is there an easy way to do this in R without going into nested loops?

thanks!

r

Hello diogo.camacho.2008!

We believe that this post does not fit the main topic of this site.

Not related to bioinformatics; perhaps try Stack Overflow

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

0 answers

No answers yet.

Log in to answer this question.