This is essentially rmultinom
with a different interface.
rspin(n, probs, labels = 1:length(probs))
number of spins of spinner
a vector of probabilities. If the sum is not 1, the probabilities will be rescaled.
a character vector of labels for the categories
rspin(20, prob=c(1,2,3), labels=c("Red", "Blue", "Green"))
#> Red Blue Green
#> 1 5 7 8
do(2) * rspin(20, prob=c(1,2,3), labels=c("Red", "Blue", "Green"))
#> Using parallel package.
#> * Set seed with set.rseed().
#> * Disable this message with options(`mosaic:parallelMessage` = FALSE)
#> Red Blue Green .row .index
#> 1 3 6 11 1 1
#> 2 2 6 12 1 2