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
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Imports:
naniar,
prodlim,
quarto,
rlang,
scales,
stats,
stringr,
Expand Down
27 changes: 26 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 @@ -111,6 +111,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)
pop.naa.fish.max <- max(data$estimate)

# 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
25 changes: 25 additions & 0 deletions R/plot_biomass_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,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)
pop.baa.fish.max <- max(data$estimate)

# 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
22 changes: 22 additions & 0 deletions R/plot_fishing_mortality.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,28 @@ plot_fishing_mortality <- function(

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

# Obtain relevant key quantities for captions/alt text
F.ref.pt <- as.character(ref_line)
F.start.year <- min(prepared_data$year)
F.end.year <- max(prepared_data$year)
F.min <- min(prepared_data$estimate)
F.max <- max(prepared_data$estimate)

# calculate & export key quantities
export_kqs(F.ref.pt,
F.start.year,
F.end.year,
F.min,
F.max)

# Add key quantities to captions/alt text
insert_kqs(F.ref.pt,
F.start.year,
F.end.year,
F.min,
F.max)

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)
cpue.max <- max(prepared_data$estimate)
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
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
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
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)
landings.max <- max(prepared_data$estimate)
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
19 changes: 19 additions & 0 deletions R/plot_recruitment_deviations.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,25 @@ plot_recruitment_deviations <- function(
} else {
selected_dat <- dat
}

# Obtain relevant key quantities for captions/alt text
recruit.dev.start.year <- min(filter_data$year)
recruit.dev.end.year <- max(filter_data$year)
recruit.dev.min <- min(filter_data$estimate)
recruit.dev.max <- max(filter_data$estimate)

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

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

create_rda(
object = final,
# get name of function and remove "plot_" from it
Expand Down
32 changes: 32 additions & 0 deletions R/plot_stock_recruitment.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,38 @@ plot_stock_recruitment <- function(

# Make RDA
if (make_rda) {

# Obtain relevant key quantities for captions/alt text
sr.age.min <- dat |>
dplyr::filter(!is.na(year) & !is.na(age)) |>
dplyr::slice(which.min(age)) |>
dplyr::select(age) |>
as.numeric()
sr.ssb.units <- spawning_biomass_label
sr.ssb.min <- min(sr$spawning_biomass, na.rm = TRUE)
sr.ssb.max <- max(sr$spawning_biomass, na.rm = TRUE)
sr.min <- min(sr$predicted_recruitment, na.rm = TRUE)
sr.max <- max(sr$predicted_recruitment, na.rm = TRUE)
sr.units <- recruitment_label

# calculate & export key quantities
export_kqs(sr.age.min,
sr.ssb.units,
sr.ssb.min,
sr.ssb.max,
sr.min,
sr.max,
sr.units)

# Add key quantities to captions/alt text
insert_kqs(sr.age.min,
sr.ssb.units,
sr.ssb.min,
sr.ssb.max,
sr.min,
sr.max,
sr.units)

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