Skip to content

Keep zero estimates in impact plots - #19

Open
david-mears-2 wants to merge 1 commit into
mainfrom
fix/retain-zero-impact-points
Open

david-mears-2 wants to merge 1 commit into
mainfrom
fix/retain-zero-impact-points

Conversation

@david-mears-2

Copy link
Copy Markdown
Contributor

The bug

plot_impact() shows the estimated health benefit of vaccination over time, such as the number of cases averted each year. It also supports grouping estimates by birth cohort.

The function removes estimates equal to zero before drawing the plot. For example, estimates of 10 cases averted in 2020, 0 in 2021, and 10 in 2022 become just the two points for 2020 and 2022. The line joins those points at 10, hiding the year with no estimated benefit. The same problem affects the birth-cohort view.

A zero estimate is a value to plot, not a missing observation.

The fix

Keep zero estimates in the plotting data so that the line drops to zero and rises again in this example. Continue removing missing (NA) estimates.

Preserve the existing error when the filtered data has no nonzero estimates, including all-zero inputs. That check now happens separately from filtering the plotting data. Negative estimates remain supported.

This PR addresses only zero removal; it does not change country selection or other plotting behavior. It also updates the patch version to 0.0.7 and records the fix in NEWS.md, as required by CONTRIBUTING.md.

Tests

The regression checks the actual coordinates of both the line and point layers, not just whether a plot is returned. It covers year and birth-cohort views, a 10, 0, 10 trajectory, a negative-to-positive trajectory through zero, and missing estimates. A second test checks that all-zero or absent outcomes still raise an error even when another outcome has nonzero estimates.

  • Confirmed that the trajectory regression fails before the fix: the middle point and its x-coordinate are missing.
  • Full package suite passes after the fix: 200 assertions, no failures, warnings, or skips, including the unchanged visual snapshots (R 4.3.3, dplyr 1.2.1, ggplot2 4.0.3).
  • Both new tests also pass with dplyr 1.1.4 and ggplot2 3.4.4. That environment has two existing visual-snapshot differences, so this older-version result is for the new tests, not a passing full suite.
  • R CMD INSTALL succeeds, and both new tests pass against the installed package.
  • The test file passes the configured linters. The source file has three namespace warnings also present on unchanged main; this patch adds no lint findings.

Retain zero-valued observations in mixed impact series while preserving the existing no-nonzero-estimates error. Add coordinate regressions for both views and update the patch release notes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@david-mears-2

Copy link
Copy Markdown
Contributor Author

This is AI generated. TODO:

  • Visual verification

This branch has not been deployed

No deployments
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 this pull request may close these issues.

2 participants