Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uncount() currently works with non-integer weights where it probably should not. Also the error message for negative weights is quite unclear.
uncount()
library(tidyr) # no error tibble(x = c("a", "b"), n = c(1, 0.5)) %>% uncount(n) #> # A tibble: 1 x 1 #> x #> <chr> #> 1 a # unclear error message tibble(x = c("a", "b"), n = c(1, -1)) %>% uncount(n) #> Error in rep(seq_nrow(data), w): invalid 'times' argument
Created on 2020-12-07 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered:
I think it's traditional for R to round down counts, e.g. rep(1:2, c(1, 0.5)), but I think you're right that the tidyverse can do better here (barring FP challenges).
rep(1:2, c(1, 0.5))
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
uncount()
currently works with non-integer weights where it probably should not. Also the error message for negative weights is quite unclear.Created on 2020-12-07 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: