powered by
Replace the sample function in the context of fixed quantiles. Warning : first argument has less features.
sampleQ(x, size, quantiles, replace = FALSE, prob = NULL)
a vector of length size with elements drawn from x.
a vector of one or more elements from which to choose.
a non-negative integer giving the number of items to choose.
1D array containing values drawn in U(0,1). Length has to be equal to size.
should sampling be with replacement ?
a vector of probability weights for obtaining the elements of the vector being sampled.
set.seed(1) quantiles <- runif(40) sampleQ(1:10, 10, quantiles[1:10]) sampleQ(1:10, 10, quantiles[11:20]) sampleQ(11:20, 10, quantiles[1:10]) sampleQ(1:10, 20, quantiles[21:40], replace = TRUE)
Run the code above in your browser using DataLab