Down-samples or samples with replacement so each group has the same number of rows.
Examples
df <- data.frame(group = rep(c("a", "b"), c(2, 5)), value = seq_len(7))
balance_samples(df, group = "group")
#> # A tibble: 4 × 2
#> group value
#> <chr> <int>
#> 1 a 1
#> 2 a 2
#> 3 b 6
#> 4 b 5
