Randomizing Data

Description

randomize permutates independently the entries in each column of a matrix-like object, to produce random data that can be used in permutation tests or bootstrap analysis.

Usage

randomize(x, ...)

Arguments

x
data to be permutated. It must be an object suitable to be passed to the function apply.
...
extra arguments passed to the function sample.

Value

a matrix

Details

In the context of NMF, it may be used to generate random data, whose factorization serves as a reference for selecting a factorization rank, that does not overfit the data.

Examples


x <- matrix(1:32, 4, 8)
randomize(x)
##      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
## [1,]    3    8   11   14   19   22   25   30
## [2,]    4    7    9   13   18   21   27   31
## [3,]    2    5   10   16   20   24   26   32
## [4,]    1    6   12   15   17   23   28   29
randomize(x)
##      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
## [1,]    3    8    9   14   17   24   28   32
## [2,]    1    5   12   13   19   22   27   30
## [3,]    2    6   11   16   20   23   26   31
## [4,]    4    7   10   15   18   21   25   29