Repository navigation
Conversation
…oss possible columns og code for interactive filtering of module_name, now extended to also work for model column
users may interactively choose model(s) to plot from the terminal, akin to module selection
…orecast year was occurring bc of use of ifelse which only returns the first value of a vector
|
@Schiano-NOAA this is the code for what we were talking about yesterday. Its not explicitly necessary for the multi-model features that were previously merged, but this ensures that tables don't get wonky when multiple models are present in the data. |
sbreitbart-NOAA
left a comment
There was a problem hiding this comment.
Thanks for developing this feature- I think it'll be very useful down the road! I've added some questions and suggestions and wanted to share them before I start testing the code later today/tomorrow.
Changed `kws` to `pretty_columns`
There was a problem hiding this comment.
Thanks for addressing my comments. I think this looks really good now. One last note is that some plots are still leaving "selected_model" as an object in the R environment- that obj should be removed at the very end (example: plot_biomass()). I'm going to start a review from copilot but assuming that goes fine, I'll merge this in!
EDIT: Copilot raised several imporant points. Please address those (or at least respond with why they're irrelevant).
During testing, I noticed that several of my own examples gave various errors; however, I don't think those failures apply to this PR so I'll make an issue if they persist.
There was a problem hiding this comment.
🟡 Changes recommended
Selecting multiple models can crash, while several plots and tables inconsistently apply model selections, producing incorrect data, reference lines, or captions.
9 open issues
Use a scalar check for multi-model selection · New Use the selected model when calculating caption quantities · New Filter reference lines to the selected models · New Resolve model selection before discovering labels · New Restore interval suppression and lognormal processing · New Handle model-less input without a NULL filter predicate · New Disable multiple-model selection for single-model table · New Forward the selected model to the table filter · New Apply single-model fallback before filtering · New
9 files not reviewed
man/conout_bam.Rd: Generated fileman/conout_rceattle.Rd: Generated fileman/conout_ss3.Rd: Generated fileman/convert_output.Rd: Generated fileman/filter_data.Rd: Generated fileman/filter_interactive.Rd: Generated fileman/plot_abundance_at_age.Rd: Generated fileman/plot_biomass.Rd: Generated fileman/plot_biomass_at_age.Rd: Generated file
What changed in this PR
This PR extends stockplotr’s existing interactive module selection to models, allowing users to choose assessments from combined datasets when creating plots and tables.
Changes:
- Generalize selection logic for models and modules, including an “All” model option.
- Add
modelparameters across plotting and table functions and reuse selections in composite tables. - Update API documentation and existing multi-model tests.
| File | Description |
|---|---|
| tests/testthat/test-utils_plot.R | Select both models explicitly in filtering tests. |
| tests/testthat/test-plot_spawning_biomass.R | Specify models in the multi-model plot test. |
| tests/testthat/test-plot_abundance_at_age.R | Specify models in the multi-model plot test. |
| R/utils_plot.R | Add shared interactive selection and model filtering. |
| R/table_total_catch.R | Add model argument and single-model selection settings. |
| R/table_projections.R | Reuse model selection and adjust rounding and deduplication. |
| R/table_landings.R | Add model argument and single-model selection settings. |
| R/table_index.R | Expose model selection and clean up selection state. |
| R/table_biomass_abundance_catch.R | Reuse one model selection across quantities. |
| R/plot_stock_recruitment.R | Forward model selection to data filtering. |
| R/plot_spr.R | Forward model selection to data filtering. |
| R/plot_spawning_biomass.R | Add model selection and filter reference-layer input. |
| R/plot_selectivity.R | Forward model selection to data filtering. |
| R/plot_recruitment.R | Forward model selection to data filtering. |
| R/plot_recruitment_deviations.R | Forward model selection to data filtering. |
| R/plot_natural_mortality.R | Forward model selection to data filtering. |
| R/plot_landings.R | Add model selection and remove interval preprocessing. |
| R/plot_index.R | Forward model selection to data filtering. |
| R/plot_fishing_mortality.R | Forward model selection to data filtering. |
| R/plot_discard.R | Forward model selection to data filtering. |
| R/plot_catch_at_age.R | Forward model selection to data filtering. |
| R/plot_biomass.R | Forward model selection to data filtering. |
| R/plot_biomass_at_age.R | Forward model selection to data filtering. |
| R/plot_abundance_at_age.R | Document and forward model selection. |
| man/table_total_catch.Rd | Document the model parameter. |
| man/table_projections.Rd | Document the model parameter. |
| man/table_landings.Rd | Document the model parameter. |
| man/table_index.Rd | Document the model parameter. |
| man/table_biomass_abundance_catch.Rd | Document the model parameter. |
| man/plot_stock_recruitment.Rd | Document the model parameter. |
| man/plot_spr.Rd | Document the model parameter. |
| man/plot_spawning_biomass.Rd | Document the model parameter. |
| man/plot_selectivity.Rd | Document the model parameter. |
| man/plot_recruitment.Rd | Document the model parameter. |
| man/plot_recruitment_deviations.Rd | Document the model parameter. |
| man/plot_natural_mortality.Rd | Document the model parameter. |
| man/plot_landings.Rd | Document the model parameter. |
| man/plot_index.Rd | Document the model parameter. |
| man/plot_fishing_mortality.Rd | Document the model parameter. |
| man/plot_discard.Rd | Document the model parameter. |
| man/plot_catch_at_age.Rd | Document the model parameter. |
| man/plot_biomass.Rd | Document the model parameter. |
| man/plot_biomass_at_age.Rd | Document the model parameter. |
| man/plot_abundance_at_age.Rd | Document the model parameter. |
| man/filter_interactive.Rd | Add documentation for the shared selection helper. |
| man/filter_data.Rd | Document model filtering and selection cardinality. |
| man/convert_output.Rd | Refresh usage and converter argument descriptions. |
| man/conout_ss3.Rd | Refresh converter argument documentation. |
| man/conout_rceattle.Rd | Refresh converter argument documentation. |
| man/conout_bam.Rd | Refresh converter argument documentation. |
Review effort: Balanced
| group = group, | ||
| facet = facet, | ||
| module = module, | ||
| model = model, |
There was a problem hiding this comment.
Seems worth looking into, though may be moot or different after rebasing with the main branch, which has Eric's PR merged in now
There was a problem hiding this comment.
Im not sure I really understand this comment...
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…and allow_multiple_selection=FALSE


What is the feature?
How have you implemented the solution?
moduleparameter was added to allplot_*andtable_*functions to facilitate allowing users to filter by model directly from the function call. Forplot_*functions, multiple models may be selected (an "All" option is also available to allow for quick plotting of all available models), but only one model may be selected fortable_*functions.Does the PR impact any other area of the project, maybe another repo?
PR contribution checklist
Thank you for contributing to stockplotr! Please check the boxes below to confirm this pull request (PR) is ready for review. Edit this PR description to add the release indicator and any explanations.