## generate 10 random partitions of groups of equal size
comboGroupsSample(10, 2, n = 10, seed = 123)
## generate 10 random partitions of groups of varying sizes
comboGroupsSample(10, grpSizes = 1:4, n = 10, seed = 123)
## using sampleVec to generate specific results
comboGroupsSample(15, 5, sampleVec = c(1, 100, 1e3, 1e6))
all.equal(comboGroupsSample(10, 5,
sampleVec = 1:comboGroupsCount(10, 5)),
comboGroups(10, 5))
## Examples with enormous number of total results
num = comboGroupsCount(100, 20)
gmp::log2.bigz(num)
## [1] 325.5498
first = gmp::urand.bigz(n = 1, size = 325, seed = 123)
mySamp = do.call(c, lapply(0:10, function(x) gmp::add.bigz(first, x)))
class(mySamp)
## [1] "bigz"
## using the sampling function
cbgSamp = comboGroupsSample(100, 20, sampleVec = mySamp)
## using the standard function
cbgGeneral = comboGroups(100, 20,
lower = first,
upper = gmp::add.bigz(first, 10))
identical(cbgSamp, cbgGeneral)
## [1] TRUE
if (FALSE) {
## Using Parallel
system.time(comboGroupsSample(1000, 20, n = 80, seed = 10, Parallel = TRUE))
}
Run the code above in your browser using DataLab