## generate 10 random combinations
comboSample(30, 8, TRUE, n = 5, seed = 10)
## Using sampleVec to generate specific permutations
fqs = c(1,2,2,1,2,2,1,2,1,2,2,1,2,1,1)
s_idx = c(1, 10^2, 10^5, 10^8, 10^11)
permuteSample(15, 10, freqs = fqs, sampleVec = s_idx)
## Same example using 'table' method
permuteSample(table(rep(1:15, times = fqs)), 10, sampleVec = s_idx)
## Generate each result one by one...
## Same, but not as efficient as generating iteratively
all.equal(comboSample(10, 5, sampleVec = 1:comboCount(10, 5)),
comboGeneral(10, 5))
## Examples with enormous number of total permutations
num = permuteCount(10000, 20)
gmp::log2.bigz(num)
first = gmp::urand.bigz(n = 1, size = 265, seed = 123)
mySamp = do.call(c, lapply(0:10, function(x) gmp::add.bigz(first, x)))
class(mySamp)
## using permuteSample
pSamp = permuteSample(10000, 20, sampleVec = mySamp)
## using permuteGeneral
pGeneral = permuteGeneral(10000, 20,
lower = first,
upper = gmp::add.bigz(first, 10))
identical(pSamp, pGeneral)
## Using nThreads
permPar = permuteSample(10000, 50, n = 8, seed = 10, nThreads = 2)
## Using FUN
permuteSample(10000, 50, n = 4, seed = 10, FUN = sd)
if (FALSE) {
## Using Parallel
permuteSample(10000, 50, n = 80, seed = 10, Parallel = TRUE)
}
Run the code above in your browser using DataLab