Groups a dataframe by the specified feature, selects n of these groups and discards the rest. Returned dataframe is ungrouped.
rand_n_groups(df, group_var, n)
df | A data frame or data frame like object recognized by |
---|---|
group_var | Feature to group by. Uses NSE like dplyr verbs. |
n | Number of groups to take. If there are fewer than |
Dataframe with n random groups selected according to specified grouping feature.
rand_n_groups(mtcars, cyl, 2)#> Error in (function (x) { x})(group_quo): object 'group_quo' not found