Samples n elements from vector x even if x is size 1 (https://stackoverflow.com/questions/13990125/sample-from-vector-of-varying-length-including-1)
1 | sample.vec(x,n)
|
x |
vector to sample from |
size |
a non-negative integer giving the number of items to choose. |
replace |
should sampling be with replacement? (default=FALSE) |
prob |
a vector of probability weights for obtaining the elements of the vector being sampled. |
useHash |
logical indicating if the hash-version of the algorithm should be used. Can only be used for replace = FALSE, prob = NULL, and size <= n/2, and really should be used for large n, as useHash=FALSE will use memory proportional to n. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.