You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
I am filtering a tibble and then want to sample a fraction of rows. It may well be the case that I get zero rows after filtering. In that case I expect slice_sample(prop = ???) to equally return zero rows, since 60% of zero is still zero.
This works fine as long as I don't use weight_by. If I try to weight by a column, slice_sample fails on zero-row tibbles.
Tested on CRAN and on today's github dplyr 1.0.4.9000 (Windows)
tibble(dummy=character(), weight=numeric(0)) %>% slice_sample(prop=0.5)
# A tibble: 0 x 2# ... with 2 variables: dummy <chr>, weight <dbl>
tibble(dummy=character(), weight=numeric(0)) %>% slice_sample(prop=0.5, weight_by=weight)
# Error in sample.int(n, min(size, n), prob = wt) : # too few positive probabilities
The text was updated successfully, but these errors were encountered:
I am filtering a tibble and then want to sample a fraction of rows. It may well be the case that I get zero rows after filtering. In that case I expect
slice_sample(prop = ???)
to equally return zero rows, since 60% of zero is still zero.This works fine as long as I don't use
weight_by
. If I try to weight by a column,slice_sample
fails on zero-row tibbles.Tested on CRAN and on today's github dplyr 1.0.4.9000 (Windows)
The text was updated successfully, but these errors were encountered: