shuffle_rowwise: Randomize entries in matrix while keeping row sums fixed

Description Usage Arguments Details Value Author(s) Examples

View source: R/RcppExports.R

Description

This is a utility function and as such probably not of much interest for a typical user.

Usage

1

Arguments

inmat

numeric or integer matrix, 0/1 matrix

Details

The returned matrix will not have column and row names even if the input matrix had them.

Value

a randomized matrix with the same dimensions as inmat, where the sum of values within a row remains constant

Author(s)

Christof Neumann

Examples

1
2
3
4
5
6
7
xdata <- matrix(ncol = 8, nrow = 5)
xdata[] <- sample(c(0, 1), length(xdata), TRUE)
res <- testingtravis:::shuffle_rowwise(xdata)
# row sums are constant
rowSums(xdata) == rowSums(res)
# column sums are not (although some may be, by chance)
colSums(xdata) == colSums(res)

gobbios/testingtravis documentation built on July 26, 2020, 7:22 a.m.