Description Usage Arguments Details Value Author(s) Examples
This is a utility function and as such probably not of much interest for a typical user.
1 | shuffle_checkerboard(inmat, swaps = 1L, checkerboards_only = TRUE)
|
inmat |
numeric or integer matrix, 0/1 matrix |
swaps |
numeric, the number of (attempted/trial) swaps to perform
(default is |
checkerboards_only |
logical, should the random selection of trial
matrices to be swapped be constrained to checkerboards (default is
|
The algorithm starts by selecting a random submatrix with 2 rows
and 2 columns (trial matrix). An actual swap is performed if this
selected submatrix is a checkerboard. If checkerboards_only =
TRUE, then the random selection is constrained to existing
checkerboards. In other words, if checkerboards_only = FALSE
a lot of swaps will not result in an actual swap and hence the
final matrix will be 'less' randomized.
There is no accepted value to set swaps. One rule of thumb
is to set it to double the number of 1's in the matrix (i.e.
sum(inmat) * 2).
The returned matrix will not have column and row names even if the input matrix had them.
a randomized matrix with the same dimensions as inmat, where
row and column sums are constant
Christof Neumann
1 2 3 4 5 6 7 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.