Baptiste Coulmont
2011-Feb-10 16:11 UTC
[R] randomly generated binary matrix (with conditions)
I want to create a randomly generated 25*15 binary matrix knowing what the colSums and rowSums of this matrix should be. colSums(a) [1] 3 7 2 5 0 4 6 5 5 4 3 4 4 5... rowSums(a) [1] 8 6 6 6 6 6 5 5 5 5 4 4 4... . . Baptiste Coulmont coulmont at yahoo.com --------
Baptiste Coulmont <coulmont <at> yahoo.com> writes:> > I want to create a randomly generated 25*15 binary matrix knowing what the > colSums and rowSums of this matrix should be. > > colSums(a) > [1] 3 7 2 5 0 4 6 5 5 4 3 4 4 5... > rowSums(a) > [1] 8 6 6 6 6 6 5 5 5 5 4 4 4... >This is a fairly challenging problem about which a lot has been written in the field of quantitative ecology. See ?commsimulator in the vegan package. Ben Bolker