Description Usage Arguments Details Value Author(s) Examples
Draw a sorted random sample from a vector, conserving the original order of the elements.
1 | sorted_sample(x, size, replace = FALSE, prob = NULL)
|
x |
either a vector of one or more elements from which to choose, or a positive integer. See ‘Details.’ |
size |
a non-negative integer giving the number of items to choose. |
replace |
should sampling be with replacement? |
prob |
a vector of probability weights for obtaining the elements of the vector being sampled. |
Note that the sample is not actually sorted, but reorder by
matching it back with match
to the original vector.
A vector with the sample according to the original order.
Dominik Mueller
1 2 3 | sorted_sample(letters, 5L)
sorted_sample(letters[seq_len(3L)], 10L, replace = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.