I have this matrix in R,


   s1 s2 s3 s4
g1  1  0  0  0
g1  0  1  0  0
g1  0  0  1  0
g2  1  0  0  0
g2  0  1  0  0
g3  1  0  0  0
g4  0  0  1  0
g4  1  0  0  0
g4  0  1  0  0
g4  0  0  0  1


I want to split this matrix based on its rows then sum based on columns,
finally I want to make this matrix:

   s1 s2 s3 s4
g1  1  1  1  0
g2  1  1  0  0
g3  1  0  0  0
g4  1  1  1  1

I will appreciate if you guide me.

Regards,
Soheila

	[[alternative HTML version deleted]]

