Warn if result from filter_*() is empty
- Dominant language
- R
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
`filter_pollutants()`, `filter_categories()`, and `filter_facilities()` should probably issue a warning if the result they return is empty. This will help prevent, or at least diagnose, crashes when evaluating expressions like:
```
some_data_with_no_PM2.5 %>%
filter_pollutants(
"PM2.5") %>%
chart_annual_emissions()
```
`rlang::is_empty(x)` seems like a suitable test to use within the body of `filter_*()`, just before the result is returned. It returns `TRUE` if `x` is `NULL`, and it also returns `TRUE` if `nrow(x)` is a zero-length data frame.
One question is whether the warning should be issued when:
- `verbose` is `FALSE`; or
- `verbose` is not explicitly supplied
... to `filter_*()`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading filter_pollutants(), filter_categories(), and filter_facilities() to compare their return paths and existing verbose handling. Clarify when the warning should apply, then verify the behavior for empty results and each relevant verbose setting with tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100