Ensure that all growth factors are finite numbers
- Dominant language
- R
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
# Notes
Probably best to add a check in `BY:::project_annual_quantities_by()` for this condition. This function is called by `project_annual_throughputs_by()`, which is called by the (user-facing) `area_source_projections()`.
There could be a `force = TRUE` option or something else to override it, though I'm not sure that's really appropriate. Better for users to have to filter out `NA`s from growth factor data upstream.
One way would be to change this chunk:
https://github.com/BAAQMD/BY/blob/dbfd9958e8b7d2afc8f995bdcf5cae3ded8919cb/R/project_annual_quantities_by.R#L30-L42
... by inserting an `ensure()` clause, like so:
```
projected_data <-
inner_join(
base_year_data,
using,
by = by_vars) %>%
rename(
gf_qty = !!growth_var) %>%
ensure(
all(is.finite(gf_qty))) %>% # fail if gf_qty is NA
mutate_at(
vars(value_vars),
~ . * gf_qty) %>%
dplyr::select(
names(input_data),
gf_qty)
```
It would be better to be more verbose and descriptive with a warning, though.
# Related Issues
- https://github.com/BAAQMD/BY2015-methodology/issues/221#issuecomment-821402295
# Steps to Close
- [ ] Design a process that's better than the suggestion above
- [ ] Implement it
- [ ] Add test(s) to ensure it fails as expected
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in R/project_annual_quantities_by.R around the linked lines and trace how project_annual_quantities_by() is called by project_annual_throughputs_by() and area_source_projections(). Review the proposed finite-growth-factor check and determine the warning or failure behavior. Done means the chosen validation is implemented and tests confirm invalid growth factors fail as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100