| smpl | R Documentation |
Samples a vector, factor or data.frame. Useful to reduce size of testthat expect_* tests.
Not intended for other purposes.
Wraps sample.int(). data.frames are sampled row-wise.
The seed is set within the function with sample.kind as "Rounding"
for compatibility with R versions < 3.6.0. On exit, the random state is restored.
smpl(data, n, keep_order = TRUE, seed = 42)
data |
|
n |
Number of elements/rows to sample. N.B. No replacement is used, why |
keep_order |
Whether to keep the order of the elements. (Logical) |
seed |
The |
When `data` has <=`n` elements, `data` is returned.
Otherwise, `data` is sampled and returned.
Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk
# Attach packages
library(xpectr)
smpl(c(1,2,3,4,5), n = 3)
smpl(data.frame("a" = c(1,2,3,4,5), "b" = c(2,3,4,5,6), stringsAsFactors = FALSE), n = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.