Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/update-rceattle-example-data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Update example data when convert_output.R or variable-name resources change
name: update-rceattle-example-data
on:
pull_request:
branches: [main]
paths:
- 'R/convert_output.R'
- 'inst/resources/rceattle_var_names.csv'
workflow_dispatch:
jobs:
update-example-data:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }}

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pak, any::usethis, local::.

- name: Update example data
run: Rscript data-raw/DATASET_RCEATTLE.R

- name: Commit and push updated example data
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add data/pollock.rda
git diff --cached --quiet || git commit -m "chore: update rceattle pollock example from converter resource changes (triggered by $(git log -1 --pretty=format:'%h %s' HEAD)) [skip ci]"
git push
10 changes: 10 additions & 0 deletions data-raw/DATASET_BAM.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## code to prepare `VermilionSnapper` dataset goes here
# Path to SS3 output file
EX_REPORT_PATH <- file.path("inst", "extdata", "VermilionSnapper.rdat")
# Install stockplotr
pak::local_install(".")
# Convert output
VermilionSnapper <- stockplotr::convert_output(EX_REPORT_PATH)
VermilionSnapper <- subset(VermilionSnapper, year > 1980)
# Save object as rda into raw_data
usethis::use_data(VermilionSnapper, overwrite = TRUE)
24 changes: 24 additions & 0 deletions data-raw/DATASET_RCEATTLE.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## code to prepare `RCEATTLE DATASET` dataset goes here
# Run Rceattle
install.packages(c("remotes")) # , "readxl"
remotes::install_github("afsc-assessments/Rceattle")
# library(Rceattle)
# library(readxl)
Rceattle::data("GOApollock")

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.

I get this error when running locally:

Error: 'data' is not an exported object from 'namespace:Rceattle'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hmm I will test again because idk what it could be from if not.

GOApollock$styr = 1977 # The SAFE model starts at 1970, so change styr to 1970 to run the full time series model (data is in there). I start them all at 1977 because thats the years with overlap.
pollock_model <- Rceattle::fit_mod(
data_list = GOApollock,
inits = NULL, # Initial parameters = 0
file = NULL, # Don't save
estimateMode = 0, # 0 = Estimate, 1 = Dont run estimation
random_rec = FALSE, # No random recruitment
msmMode = 0, # 0 = Single species mode, 1 = MSVPA multi-species mode
verbose = 1, # Silence optimization output
phase = TRUE) # Use default phasing
# Install stockplotr
pak::local_install(".")
# Convert output
# OK not to subset bc small
pollock <- stockplotr::convert_output(pollock_model)
# Save object as rda into raw_data
usethis::use_data(pollock, overwrite = TRUE)
13 changes: 13 additions & 0 deletions data-raw/DATASET_SS3.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## code to prepare `ss3_simple` dataset goes here

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.

This works fine but I think the documentation (and filename) should be edited to clarify that this isn't converting raw SS3 output-- instead, SS3 output that's been formatted into a list by r4ss. Filename could be updated to something like "DATASET_SS3-r4ss.R", esp. if we're planning to retain the original "DATASET.R" file, which is also based on SS3 output

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.

Second question: are we retaining "DATASET.R"? I suppose we should, until SS3 output conversion is offically deprecated

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yep right on the nose

install.packages(c("remotes"))
remotes::install_github("r4ss/r4ss")
# Path to SS3 output file
r4ss_files <- system.file("extdata", "simple_small", package = "r4ss")
EX_REPORT_PATH <- r4ss::SS_output(r4ss_files)
# Install stockplotr
pak::local_install(".")
# Convert output
ss3_simple <- stockplotr::convert_output(EX_REPORT_PATH)
# Save object as rda into raw_data
# replace with example_data once report file is deprecated
usethis::use_data(ss3_simple, overwrite = TRUE)
Binary file added data/VermilionSnapper.rda
Binary file not shown.
Binary file added data/pollock.rda
Binary file not shown.
Binary file added data/ss3_simple.rda
Binary file not shown.
34,060 changes: 34,060 additions & 0 deletions inst/extdata/VermilionSnapper.rdat

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.

This adds >10 MB to the package. Can we reduce its size? Or will its size not impact package loading?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I am currently looking into different approaches. I also need to add documentation for each dataset as an md file

Large diffs are not rendered by default.

Loading