According to dplyr 1.0.9 slice() documentation "If n is greater than the number of rows in the group (or prop > 1), the result will be silently truncated to the group size." However this is not true if using group_by() and slice_sample().
df <- tibble(
group = rep(c("a", "b", "c"), c(1, 2, 4)),
x = runif(7)
)
df %>% group_by(group) %>% slice_sample(n = 2)
Error in slice_sample(): ! Problem while computing indices. i The
error occurred in group 1: group = "a". Caused by error in
sample.int(): ! cannot take a sample larger than the population when
'replace = FALSE' Run rlang::last_error() to see where the error
occurred.