Skip to content
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

Warn if result from filter_*() is empty #9

Open
dholstius opened this issue May 6, 2020 · 0 comments
Open

Warn if result from filter_*() is empty #9

dholstius opened this issue May 6, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@dholstius
Copy link
Member

dholstius commented May 6, 2020

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_*().

@dholstius dholstius changed the title Empty result from filter_*() Warn if result from filter_*() is empty Apr 12, 2021
@dholstius dholstius added the enhancement New feature or request label Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant