powered by
sample n rows by group from a table using the sample_n() function.
sample_n()
sample_n_by(data, ..., size = 1, replace = FALSE)
a data frame
Variables to group by
the number of rows to select
with or without replacement?
ToothGrowth %>% sample_n_by(dose, supp, size = 2)
Run the code above in your browser using DataLab