Given a tidy-format data frame of draws with a column indexing each draw, subsample the data frame to a given size based on a column indexing draws, ensuring that rows in sub-groups of a grouped data frame are sampled from the same draws.
sample_draws(data, ndraws, draw = ".draw", seed = NULL)Data frame to sample from
The number of draws to return, or NULL to return all draws.
The name of the column indexing the draws; default ".draw".
A seed to use when subsampling draws (i.e. when ndraws is not NULL).
Matthew Kay
sample_draws() makes it easier to sub-sample a grouped, tidy-format data frame of draws. On a grouped data frame,
the naive approach of using filter with the .draw column will give incorrect results as it will
select a different sample within each group. sample_draws() ensures the same sample is selected within
each group.