Skip to content

Silently drop NULLs in summarise()? #5708

New issue

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

Closed
hadley opened this issue Jan 26, 2021 · 0 comments · Fixed by #5710
Closed

Silently drop NULLs in summarise()? #5708

hadley opened this issue Jan 26, 2021 · 0 comments · Fixed by #5710
Assignees
Milestone

Comments

@hadley
Copy link
Member

hadley commented Jan 26, 2021

This would be consistent with our general principles for handling NULL, and would support workflows like this:

library(dplyr, warn.conflicts = FALSE)
cond <- FALSE
mtcars %>% 
  summarise(
    always = mean(gear),
    optional = if(cond) mean(hp)
  )
#> Error: Problem with `summarise()` input `optional`.
#> x Input `optional` must be a vector, not NULL.
#> ℹ Input `optional` is `if (cond) mean(hp)`.

Created on 2021-01-26 by the reprex package (v0.3.0.9001)

From https://twitter.com/pheymanss/status/1354116324159606785

@romainfrancois romainfrancois self-assigned this Jan 27, 2021
@romainfrancois romainfrancois added this to the 1.1.0 milestone Jan 27, 2021
romainfrancois added a commit that referenced this issue Jan 27, 2021
romainfrancois added a commit that referenced this issue Jan 28, 2021
* summarise() silently ignore NULL results.

closes #5708

* fix mismatch with reporting group where error occured.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants