sample | R Documentation |
Take a random sample from a vector.
sample(x, size = vec_size(x), replace = FALSE, w = NULL)
x |
A vector. |
size |
Number of samples to take, Defaults to the size of |
replace |
Should samples be taken with or without replacement? |
w |
Optionally, a vector of weights. If provided should be a numeric vector the same size as x. |
sample(1:5) sample(1:100, 10) sample(1:10, 100, replace = TRUE) # samples of data frames are taken row wise, making it easy to # do bootstrapping sample(iris, 10, replace = TRUE) # Unlike base::sample(), this is safe to use with inputs of length 1 sample(3:5) sample(4:5) sample(5:5) base::sample(5:5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.