Skip to content

Silently drop NULLs in summarise()? #5708

Description

@hadley

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions