Skip to content

[feat]: compatability of r4ss::ss_output object into convert_output#288

Open
Schiano-NOAA wants to merge 18 commits into
mainfrom
conout-r4ss
Open

[feat]: compatability of r4ss::ss_output object into convert_output#288
Schiano-NOAA wants to merge 18 commits into
mainfrom
conout-r4ss

Conversation

@Schiano-NOAA

Copy link
Copy Markdown
Collaborator

This feature adds another functionality to allow users to input the "converted" output from a stock synthesis model that is run through the function ss_output in {r4ss}. This provides users multiple ways to convert the output for a stock synthesis model in the case they only have one or the other.

@Schiano-NOAA Schiano-NOAA linked an issue Jun 30, 2026 that may be closed by this pull request
@github-actions

Copy link
Copy Markdown
Contributor

New version checklist

  • Package version in DESCRIPTION has been updated
  • Release notes have been drafted/published
  • Cheatsheet content has been updated (if applicable)
  • Cheatsheet version has been updated

@github-actions

Copy link
Copy Markdown
Contributor

Code Metrics Report

Coverage Code to Test Ratio Test Execution Time
66.2% 1:0.1 7m33s

Code coverage of files in pull request scope (47.6%)

Files Coverage
R/convert_output.R 47.6%

Reported by octocov

@Schiano-NOAA

Schiano-NOAA commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Remaining todo:

  • Make alternative naming conventions sheet for r4ss names ---> no need now
  • Testing on other SS3 examples
  • ID why single_vals are not being added to conout
  • Add version check --> no need now

@Schiano-NOAA Schiano-NOAA changed the title [Feature]: compatability of r4ss::ss_output object into convert_output [feat]: compatability of r4ss::ss_output object into convert_output Jul 1, 2026
@Schiano-NOAA Schiano-NOAA marked this pull request as ready for review July 2, 2026 13:47
@Schiano-NOAA Schiano-NOAA self-assigned this Jul 2, 2026
@Schiano-NOAA Schiano-NOAA added the enhancement New feature or request label Jul 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends convert_output() to accept an r4ss::ss_output (list-like) object in addition to file-path inputs, and adds a regression test plus variable-name mappings to support this new input path.

Changes:

  • Add support for r4ss::ss_output-style list inputs to be processed as SS3 output.
  • Add a test fixture-based check that convert_output() can run on an r4ss object without error.
  • Extend ss3_var_names.csv with additional label mappings for SS3/r4ss-derived fields.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
R/convert_output.R Adds SS3 handling for list inputs (r4ss output) and adjusts parsing/normalization paths.
tests/testthat/test-convert_output.R Adds a new test that exercises convert_output() with an r4ss object fixture.
inst/resources/ss3_var_names.csv Adds/updates SS3 variable name mappings to support additional labels.
Comments suppressed due to low confidence (1)

R/convert_output.R:540

  • grepl("?_month_[0-9]_?", ...) / grepl("?_area_[0-9]_?", ...) start with ?, which is an invalid regex ("nothing to repeat") in R. This can emit warnings or fail label normalization; the intended optional underscore should be expressed as _?.
                  label = dplyr::case_when(
                    grepl("?_month_[0-9]_?", label) ~ stringr::str_replace(label, "_?month_\\d?", ""),
                    grepl("?_area_[0-9]_?", label) ~ stringr::str_replace(label, "_?area_\\d?", ""),
                    TRUE ~ stringr::str_extract(label, "^.*?(?=_\\d|_gp|_fem|_mal|_sx|:|$)")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/convert_output.R Outdated
Comment thread R/convert_output.R Outdated
Comment thread inst/resources/ss3_var_names.csv Outdated
Comment thread tests/testthat/test-convert_output.R
@sbreitbart-NOAA

Copy link
Copy Markdown
Collaborator

@Schiano-NOAA I see your checklist above isn't fully checked-off. Still ready for a review?

@Schiano-NOAA

Copy link
Copy Markdown
Collaborator Author

@sbreitbart-NOAA oh thanks! Let me add a check for the version, otherwise feel free to review. I'm fairly confident this will work for all models.

@Schiano-NOAA

Copy link
Copy Markdown
Collaborator Author

@sbreitbart-NOAA good to go for review! I think all is well here

@sbreitbart-NOAA sbreitbart-NOAA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most testing works well and quickly! Two plots don't work with the r4ss sample data, though: plot_abundance_at_age() and plot_biomass_at_age(). Both give this error:

plot_abundance_at_age(r4_out)
! Multiple module names found in data. 
ℹ Selection bypassed. Filtering by recruit.
Error in `column_data[[1]]` at stockplotr/R/process_data.R:305:5:
! Can't extract columns past the end.
ℹ Location 1 doesn't exist.
ℹ There are only 0 columns.
Run `rlang::last_trace()` to see where the error occurred.

@Schiano-NOAA

Copy link
Copy Markdown
Collaborator Author

@sbreitbart-NOAA thanks for looking at this! I will see what is going on and make adjustments 👍

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

Successfully merging this pull request may close these issues.

[feat] Update converter for SS3 to accept the r4ss output

3 participants