[R] permutations of a binary matrix with fixed margins

Mathieu Jérôme jerome.mathieu at snv.jussieu.fr
Thu Apr 5 15:34:01 CEST 2007

Dear R Users,
How can I randomize a matrix (with contains only 0 and 1) with the
constraint that margin totals (columns and rows sums) are kept constant?
Some have called this "swap permutation" or something like that.

The principle is to find bloc of
and change it for
there can be several rows or columns between these numbers.
It probably exists in R, but I can't find the function. I am aware of
permcont, but it works only for 2x2 matrices

thanks in advance

Jérôme Mathieu
Laboratory of soil tropical ecology
jerome.mathieu at snv.jussieu.fr

More information about the R-help mailing list