I'm aware there is sample_n
function in dplyr
but don't know how to pick a sample with weights.
For example;
iris %>%
group_by(Species) %>%
sample_n(size = 3)
this brings 30 observations from each group.
But I want to have 30 observation at total, and want this 30 sample to be %70 of group 1, %20 of group 2 and %10 of group 3 e.g.
Thanks in advance.