If I take a tibble and try to sample it, it works fine,
dft <- tibble(a=rnorm(200),b=seq.int(1,200),c=sample(LETTERS[1:26],200,replace = T))
sample_frac(dft,.5)
# A tibble: 100 x 3
a b c
<dbl> <int> <chr>
1 -0.233 58 S
2 0.0529 82 Y
3 0.371 31 S
4 0.978 136 Z
5 0.878 106 S
6 0.253 46 D
7 -1.07 16 W
8 -1.98 193 Y
9 -0.890 51 H
10 0.151 75 A
# ... with 90 more rows
but if I group that tibble and then try to sample the grouped tibble it returns an empty tibble.
dft <- dft %>% group_by(c) %>% count()
sample_frac(dft,.5)
# A tibble: 0 x 2
# Groups: c [0]
# ... with 2 variables: c <chr>, n <int>
If I coerce the tibble to a data.frame, the sampling works. The issue was reported as a bug and closed some time ago, so I am guessing it is not something easily fixed.
What is different about tibbles and data.frames that causes issues like this one?