Possible arrangements of binary vectors keeping sum fixed in R <p>Suppose we have fixed row sums for a matrix (say, <em>MAT</em>) of dimension <em>3 x N</em> which (i.e the row sums) are = <em>(RS,LS,NCS)'</em>. The <em>N</em> column vectors are unknown. There are 3 possible choices for each of the <em>N</em> column vectors - (1,0,0)', (0,1,0)', (0,0,1)'.</p> <p>So the <strong>first question</strong> is - </p> <p>How can we get all possible choices of this matrix <em>MAT</em> by keeping the row sums fixed as <em>(RS,LS,NCS)'</em> using R software ? </p> <p>For example - Take <em>N</em>=7, <em>RS</em>=sum of first row=2, <em>LS</em>=sum of second row=2 and <em>NCS</em>=sum of third row=3. So (1,0,0)' will appear twice, (0,1,0)' will also appear twice and (0,0,1)' will appear thrice in the set of <em>N</em> columns of that matrix <em>MAT</em>. One possible choice of <em>MAT</em> is -</p> <p>1 0 0 0 0 1 0 </p> <p>0 1 0 0 0 0 1 </p> <p>0 0 1 1 1 0 0</p> <p>I think there will be 7!/(2!x2!x3!)=210 possible choices of <em>MAT</em> by keeping the row sum fixed as (2,2,3)'. </p> <p>But how to get those possible choices of <em>MAT</em> using R software ? It should be an array of dimension 3xNxn, where <em>n</em> is the number of possible choices of <em>MAT</em>. </p> <p>The <strong>second question</strong> is- </p> <p>How the solution mechanism changes in the above problem if the possible choices of each of the <em>N</em> column vectors of that matrix <em>MAT</em> becomes - (1,1,0)', (1,0,0)', (0,1,0)', (0,0,1)' ?</p>