View source: R/subsample_groupeddf.R
subsample_groupeddf | R Documentation |
The subsample_groupeddf
function returns a subsampled version of the input data frame. If the number of rows
in a group of the input data frame is less than the specified threshold (Nthres
), all rows of that
group are returned. Otherwise, a random subset of rows, of size Nthres
, from each group is returned.
subsample_groupeddf(df, Nthres)
df |
A data frame to be subsampled. Can be grouped or ungrouped. |
Nthres |
An integer threshold for subsampling. If a group in |
A subsampled data frame.
## Not run:
data <- data.frame(group = rep(1:2, each = 100), value = rnorm(200))
subsampled_data <- subsample_groupeddf(data, 50)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.