Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c3204f2
Create first draft of key quantities template csv; start drafting pip…
sbreitbart-NOAA Mar 5, 2026
a980f12
Finished draft of key quantities pipeline for landings plot
sbreitbart-NOAA Mar 12, 2026
861ba15
Reorder KQs in plot_landings() by logical grouping; update plot_recru…
sbreitbart-NOAA Mar 17, 2026
a592458
update plot_fishing_mortality() to work with new KQ extraction/insert…
sbreitbart-NOAA Mar 17, 2026
ab3e6a7
update plot_stock_recruitment() to work with new KQ extraction/insert…
sbreitbart-NOAA Mar 17, 2026
29b25eb
update plot_abundance_at_age() to work with new KQ extraction/inserti…
sbreitbart-NOAA Mar 18, 2026
9ffb77a
update plot_biomass_at_age() to work with new KQ extraction/insertion…
sbreitbart-NOAA Mar 18, 2026
824f885
update plot_indices() to work with new KQ extraction/insertion design
sbreitbart-NOAA Mar 18, 2026
a2604b2
update plot_natural_mortality() to work with new KQ extraction/insert…
sbreitbart-NOAA Mar 18, 2026
c2acd9d
update plot_biomass() to work with new KQ extraction/insertion design
sbreitbart-NOAA Mar 19, 2026
3d2f7e8
update plot_spawning_biomass() to work with new KQ extraction/inserti…
sbreitbart-NOAA Mar 19, 2026
6ae0816
update plot_catch_comp() to work with new KQ extraction/insertion design
sbreitbart-NOAA Mar 19, 2026
0eb1e23
update plot_recruitment() to work with new KQ extraction/insertion de…
sbreitbart-NOAA Mar 19, 2026
9311468
update table_landings() to work with new KQ extraction/insertion design
sbreitbart-NOAA Mar 19, 2026
5d9d79d
Update plot_biomass() and plot_spawning_biomass() so that values are …
sbreitbart-NOAA Mar 19, 2026
34e6c6c
Update plot_fishing_mortality() so that values are accurate when rela…
sbreitbart-NOAA Mar 20, 2026
918de27
Remove write_captions() and add_more_key_quants() functions and updat…
sbreitbart-NOAA Mar 20, 2026
45abb4c
Add documentation for new functions
sbreitbart-NOAA Mar 20, 2026
6eb5fb5
Round numeric key quantities to 3 digits
sbreitbart-NOAA Mar 20, 2026
d712ee0
Update tests
sbreitbart-NOAA Mar 20, 2026
fd1b5f4
Update vignettes with new KQs workflow; change package syntax from ``…
sbreitbart-NOAA Mar 20, 2026
91063aa
Ensure age calculated properly for at_age plots; update global variables
sbreitbart-NOAA Mar 20, 2026
d9e0b58
Update vignette; add KQ meanings to template; add notes
sbreitbart-NOAA Mar 20, 2026
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
4 changes: 2 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Examples of representing our community include using an official e-mail address,
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement anonymously using this [form](https://forms.gle/MVNesUbP15bHei1J7).

Reports will be reviewed by a member of the NOAA Fisheries Office of Science and Technology who is not participating in the `stockplotr` project [Patrick Lynch] but has the full support of `stockplotr` Community Leaders. All reports will be reviewed promptly and fairly.
Reports will be reviewed by a member of the NOAA Fisheries Office of Science and Technology who is not participating in the {stockplotr} project [Patrick Lynch] but has the full support of {stockplotr} Community Leaders. All reports will be reviewed promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident whenever possible; however, please note behaviors that meet the official criteria for harrassment must be reported by supervisors under NOAA policy.

Expand Down Expand Up @@ -103,4 +103,4 @@ Community Impact Guidelines were inspired by
For answers to common questions about this code of conduct, see the FAQ at
<https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.

[homepage]: https://www.contributor-covenant.org
[homepage]: https://www.contributor-covenant.org
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Contributing to `stockplotr`
# Contributing to {stockplotr}

Do you have an idea that would improve `stockplotr`? *Consider making a contribution!* We welcome ideas for improving not only our code, but also our documentation, tutorial, and any other material associated with `stockplotr`. Here are some options and tips for doing so.
Do you have an idea that would improve {stockplotr}? *Consider making a contribution!* We welcome ideas for improving not only our code, but also our documentation, tutorial, and any other material associated with {stockplotr}. Here are some options and tips for doing so.

Note: To make any contribution, you must agree to abide by the [Code of Conduct](https://github.com/nmfs-ost/stockplotr/blob/main/CODE_OF_CONDUCT.md).

## Contributing ideas: code, documentation, etc.

### Recommended workflow: fork & submit a pull request

The most efficient way to contribute an idea is to fork `stockplotr`, make your suggested changes on a local branch, and then submit a pull request. This will allow the developers to easily evaluate your suggested changes. Please see the [GitHub Docs' "Contributing to a project" page](https://docs.github.com/en/get-started/exploring-projects-on-github/contributing-to-a-project) for step-by-step guidance in using this workflow.
The most efficient way to contribute an idea is to fork {stockplotr}, make your suggested changes on a local branch, and then submit a pull request. This will allow the developers to easily evaluate your suggested changes. Please see the [GitHub Docs' "Contributing to a project" page](https://docs.github.com/en/get-started/exploring-projects-on-github/contributing-to-a-project) for step-by-step guidance in using this workflow.

### Recommended practices

Expand All @@ -26,4 +26,4 @@ If possible, please submit a reproducible example ([reprex](https://reprex.tidyv

## Contributing questions

Have a question? Ask it in our [Discussions page](https://github.com/nmfs-ost/stockplotr/discussions). You can categorize it under General, Ideas, Q&A, and more.
Have a question? Ask it in our [Discussions page](https://github.com/nmfs-ost/stockplotr/discussions). You can categorize it under General, Ideas, Q&A, and more.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Description: Creates exploratory and finished tables and figures for stock
interprets outputs of stock assessment models as well as allows the
analyst to create report ready tables and figures, reducing the need
to create their own and format then when adding into a report. This
package is intended to be used in conjuction with `asar`, a partially
package is intended to be used in conjuction with {asar}, a partially
automated template for writing various stock assessment reports.
Throughout development, we will be creating a set of standardized
figures and tables for a stock assessment report, developing functions
Expand Down Expand Up @@ -48,6 +48,7 @@ Imports:
naniar,
prodlim,
quarto,
rlang,
scales,
stats,
stringr,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ export(reference_line)
export(save_all_plots)
export(table_landings)
export(theme_noaa)
export(write_captions)
30 changes: 29 additions & 1 deletion R/plot_abundance_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ plot_abundance_at_age <- function(
) {
# Create label for abundance units in legend
abundance_label <- label_magnitude(
label = "Abudance",
label = "Abundance",
unit_label = unit_label,
scale_amount = scale_amount
)
Expand Down Expand Up @@ -97,6 +97,9 @@ plot_abundance_at_age <- function(
ggplot2::ggplot()
)
}

data <- data |>
dplyr::mutate(age = as.numeric(age))

# Plot data
plot <- plot_aa(
Expand All @@ -111,6 +114,31 @@ plot_abundance_at_age <- function(
)
# export figure to rda if argument = T
if (make_rda == TRUE) {

# Obtain relevant key quantities for captions/alt text
pop.naa.start.year <- min(data$year)
pop.naa.end.year <- max(data$year)
pop.naa.age.min <- min(data$age)
pop.naa.age.max <- max(data$age)
pop.naa.fish.min <- min(data$estimate) |> round(digits = 3)
pop.naa.fish.max <- max(data$estimate) |> round(digits = 3)

# calculate & export key quantities
export_kqs(pop.naa.start.year,
pop.naa.end.year,
pop.naa.age.min,
pop.naa.age.max,
pop.naa.fish.min,
pop.naa.fish.max)

# Add key quantities to captions/alt text
insert_kqs(pop.naa.start.year,
pop.naa.end.year,
pop.naa.age.min,
pop.naa.age.max,
pop.naa.fish.min,
pop.naa.fish.max)

create_rda(
object = plot,
# get name of function and remove "plot_" from it
Expand Down
41 changes: 41 additions & 0 deletions R/plot_biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,47 @@ plot_biomass <- function(

### Make RDA ----
if (make_rda) {

if (relative){
# pulling out the 2nd df in 'data' works for several datasets
rel.B.min <- ggplot2::ggplot_build(final)@data[[2]] |>
as.data.frame() |>
dplyr::pull(y) |>
min()
rel.B.max <- ggplot2::ggplot_build(final)@data[[2]] |>
as.data.frame() |>
dplyr::pull(y) |>
max()

# calculate & export key quantities
export_kqs(rel.B.min, rel.B.max)

# Add key quantities to captions/alt text
insert_kqs(rel.B.min, rel.B.max)

} else {
B.min <- min(prepared_data$estimate)
B.max <- max(prepared_data$estimate)

export_kqs(B.min, B.max)
insert_kqs(B.min, B.max)
}

B.ref.pt <- as.character(ref_line)
B.units <- as.character(unit_label)
B.start.year <- min(prepared_data$year) |> round(digits = 3)
B.end.year <- max(prepared_data$year) |> round(digits = 3)

export_kqs(B.ref.pt,
B.units,
B.start.year,
B.end.year)

insert_kqs(B.ref.pt,
B.units,
B.start.year,
B.end.year)

create_rda(
object = final,
topic_label = ifelse(relative, "relative_biomass", "biomass"),
Expand Down
28 changes: 28 additions & 0 deletions R/plot_biomass_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ plot_biomass_at_age <- function(
)
}

data <- data |>
dplyr::mutate(age = as.numeric(age))

# Plot data
plot <- plot_aa(
dat = data,
Expand All @@ -95,6 +98,31 @@ plot_biomass_at_age <- function(
)
# export figure to rda if argument = T
if (make_rda == TRUE) {

# Obtain relevant key quantities for captions/alt text
pop.baa.start.year <- min(data$year)
pop.baa.end.year <- max(data$year)
pop.baa.age.min <- min(data$age)
pop.baa.age.max <- max(data$age)
pop.baa.fish.min <- min(data$estimate) |> round(digits = 3)
pop.baa.fish.max <- max(data$estimate) |> round(digits = 3)

# calculate & export key quantities
export_kqs(pop.baa.start.year,
pop.baa.end.year,
pop.baa.age.min,
pop.baa.age.max,
pop.baa.fish.min,
pop.baa.fish.max)

# Add key quantities to captions/alt text
insert_kqs(pop.baa.start.year,
pop.baa.end.year,
pop.baa.age.min,
pop.baa.age.max,
pop.baa.fish.min,
pop.baa.fish.max)

create_rda(
object = plot,
# get name of function and remove "plot_" from it
Expand Down
29 changes: 29 additions & 0 deletions R/plot_catch_comp.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ plot_catch_comp <- function(
group <- processed_data[[2]]
facet <- processed_data[[3]]
}

data <- data |>
dplyr::mutate(age = as.numeric(age))

# Plot data
plot <- plot_aa(
dat = data,
Expand All @@ -111,6 +115,31 @@ plot_catch_comp <- function(

# export figure to rda if argument = T
if (make_rda == TRUE) {

# Obtain relevant key quantities for captions/alt text
caa.start.year <- min(data$year)
caa.end.year <- max(data$year)
caa.age.min <- min(data$age)
caa.age.max <- max(data$age)
tot.catch.min <- min(data$estimate) |> round(digits = 3)
tot.catch.max <- max(data$estimate) |> round(digits = 3)

# calculate & export key quantities
export_kqs(caa.start.year,
caa.end.year,
caa.age.min,
caa.age.max,
tot.catch.min,
tot.catch.max)

# Add key quantities to captions/alt text
insert_kqs(caa.start.year,
caa.end.year,
caa.age.min,
caa.age.max,
tot.catch.min,
tot.catch.max)

create_rda(
object = plot,
# get name of function and remove "plot_" from it
Expand Down
41 changes: 41 additions & 0 deletions R/plot_fishing_mortality.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,47 @@ plot_fishing_mortality <- function(

### Make RDA ----
if (make_rda) {

if (relative){
# Obtain relevant key quantities for captions/alt text
# pulling out the 2nd df in 'data' works for several datasets
rel.F.min <- ggplot2::ggplot_build(final)@data[[2]] |>
as.data.frame() |>
dplyr::pull(y) |>
min() |>
round(digits = 2)
rel.F.max <- ggplot2::ggplot_build(final)@data[[2]] |>
as.data.frame() |>
dplyr::pull(y) |>
max() |>
round(digits = 2)

# calculate & export key quantities
export_kqs(rel.F.min, rel.F.max)

# Add key quantities to captions/alt text
insert_kqs(rel.F.min, rel.F.max)

} else {
F.min <- min(prepared_data$estimate) |> round(digits = 3)
F.max <- max(prepared_data$estimate) |> round(digits = 3)

export_kqs(F.min, F.max)
insert_kqs(F.min, F.max)
}

F.ref.pt <- as.character(ref_line)
F.start.year <- min(prepared_data$year)
F.end.year <- max(prepared_data$year)

export_kqs(F.ref.pt,
F.start.year,
F.end.year)

insert_kqs(F.ref.pt,
F.start.year,
F.end.year)

create_rda(
object = final,
topic_label = ifelse(relative, "relative_fishing_mortality", "fishing_mortality"),
Expand Down
26 changes: 25 additions & 1 deletion R/plot_indices.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ plot_indices <- function(
module = NULL,
focus = NULL,
make_rda = FALSE,
figures_dir = NULL,
figures_dir = getwd(),
...
) {
# Set cpue unit label for plot
Expand Down Expand Up @@ -114,6 +114,30 @@ plot_indices <- function(

### Make RDA ----
if (make_rda) {

# Obtain relevant key quantities for captions/alt text
cpue.start.year <- min(prepared_data$year)
cpue.end.year <- max(prepared_data$year)
cpue.min <- min(prepared_data$estimate) |> round(digits = 3)
cpue.max <- max(prepared_data$estimate) |> round(digits = 3)
cpue.units <- ifelse(unit_label == "",
"an estimated index ratio", # default if empty
unit_label)

# calculate & export key quantities
export_kqs(cpue.start.year,
cpue.end.year,
cpue.min,
cpue.max,
cpue.units)

# Add key quantities to captions/alt text
insert_kqs(cpue.start.year,
cpue.end.year,
cpue.min,
cpue.max,
cpue.units)

create_rda(
object = plt,
# get name of function and remove "plot_" from it
Expand Down
22 changes: 22 additions & 0 deletions R/plot_landings.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@ plot_landings <- function(

### Make RDA ----
if (make_rda) {

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.

Is this chunk going to be unique to all plots? Like we won't be able to generalize this and make it more concise?

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.

Line 102-108

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.

Lines 102-108 are where key quantities are calculated for this plot (and I'd expect this is where each plot/table's KQs will be calculated too). The next couple of functions are where the generalization happens: in the exporting of the KQs into a csv, and the insertion of the KQs into the alt text/captions csv.

# Obtain relevant key quantities for captions/alt text
landings.start.year <- min(prepared_data$year)
landings.end.year <- max(prepared_data$year)
landings.min <- min(prepared_data$estimate) |> round(digits = 3)
landings.max <- max(prepared_data$estimate) |> round(digits = 3)
landings.units <- unit_label

# calculate & export key quantities
export_kqs(landings.start.year,
landings.end.year,
landings.min,
landings.max,
landings.units)

# Add key quantities to captions/alt text
insert_kqs(landings.start.year,
landings.end.year,
landings.min,
landings.max,
landings.units)

create_rda(
object = plt,
# get name of function and remove "plot_" from it
Expand Down
Loading
Loading