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
37 changes: 20 additions & 17 deletions R/plot_abundance_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ plot_abundance_at_age <- function(
ggplot2::ggplot()
)
}

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

Expand All @@ -114,31 +114,34 @@ 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)

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)

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
38 changes: 20 additions & 18 deletions R/plot_biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ plot_biomass <- function(

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

if (relative){
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() |>
Expand All @@ -159,36 +158,39 @@ plot_biomass <- function(
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)


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
37 changes: 20 additions & 17 deletions R/plot_biomass_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ plot_biomass_at_age <- function(

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

# Plot data
plot <- plot_aa(
dat = data,
Expand All @@ -98,31 +98,34 @@ 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)

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)

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
39 changes: 21 additions & 18 deletions R/plot_catch_comp.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +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 @@ -115,31 +115,34 @@ 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)

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)

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
36 changes: 19 additions & 17 deletions R/plot_fishing_mortality.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ plot_fishing_mortality <- function(

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

if (relative){
# Obtain relevant key quantities for captions/alt text
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() |>
Expand All @@ -109,33 +108,36 @@ plot_fishing_mortality <- function(
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)


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
34 changes: 19 additions & 15 deletions R/plot_indices.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,30 +114,34 @@ 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)
"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)

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)

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
Loading
Loading