r_sample {rando} | R Documentation |
Generate Random Sample
Description
Generates a Sample from a set, with replacement
Usage
r_sample(sample, weights = NULL, ..., n = default_n(), .seed = NULL)
Arguments
sample |
a set of values to choose from |
weights |
a vector of weights, must be the same length as |
... |
Unused |
n |
number of observations to generate. The |
.seed |
One of the following:
To extract the random seed from a previously generated set of
values, use |
Value
A vector of length n
of the same type as sample
Examples
set_n(15)
r_sample(c("blue", "red", "yellow"))
r_sample(c("blue", "red", "yellow"),
weights = c(1, 5, 1)
)
r_sample(c("blue", "red", "yellow"), n = 10)