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 NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export(process_data)
export(process_table)
export(reference_line)
export(save_all_plots)
export(table_biomass_abundance_catch)
export(table_index)
export(table_landings)
export(table_projections)
Expand Down
3 changes: 1 addition & 2 deletions R/plot_abundance_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ plot_abundance_at_age <- function(
# get name of function and remove "plot_" from it
topic_label = gsub("plot_", "", utils::tail(as.character(sys.call()[[1]]), n = 1)),
fig_or_table = "figure",
dat,
unit_label = "mt"
dat
)
}
plot
Expand Down
3 changes: 1 addition & 2 deletions R/plot_biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,7 @@ plot_biomass <- function(
dat = rp_dat,
dir = figures_dir,
ref_line = ifelse(!is.null(names(ref_line)), names(ref_line), ref_line),
scale_amount = scale_amount,
unit_label = unit_label
scale_amount = scale_amount
)
}
# Output final plot
Expand Down
3 changes: 1 addition & 2 deletions R/plot_biomass_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ plot_biomass_at_age <- function(
# get name of function and remove "plot_" from it
topic_label = gsub("plot_", "", utils::tail(as.character(sys.call()[[1]]), n = 1)),
fig_or_table = "figure",
dat,
unit_label = "mt"
dat
)
}
plot
Expand Down
3 changes: 1 addition & 2 deletions R/plot_catch_comp.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ plot_catch_comp <- function(
# get name of function and remove "plot_" from it
topic_label = gsub("plot_", "", utils::tail(as.character(sys.call()[[1]]), n = 1)),
fig_or_table = "figure",
dat,
unit_label = "mt"
dat
)
}
plot
Expand Down
3 changes: 1 addition & 2 deletions R/plot_discard.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ plot_discard <- function(
fig_or_table = "figure",
dat = discards,
dir = figures_dir,
scale_amount = scale_amount,
unit_label = unit_label
scale_amount = scale_amount
)
}
# Output final plot
Expand Down
3 changes: 1 addition & 2 deletions R/plot_fishing_mortality.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ plot_fishing_mortality <- function(
dat = dat,
dir = figures_dir,
ref_line = ifelse(!is.null(names(ref_line)), names(ref_line), ref_line),
scale_amount = 1,
unit_label = "" # no unit for F
scale_amount = 1
)
}
# Output final plot
Expand Down
3 changes: 1 addition & 2 deletions R/plot_index.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ plot_index <- function(
topic_label = gsub("plot_", "", utils::tail(as.character(sys.call()[[1]]), n = 1)),
fig_or_table = "figure",
dat = dat,
dir = figures_dir,
unit_label = unit_label
dir = figures_dir
)
}
# Output final plot
Expand Down
3 changes: 1 addition & 2 deletions R/plot_landings.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ plot_landings <- function(
fig_or_table = "figure",
dat = dat,
dir = figures_dir,
scale_amount = scale_amount,
unit_label = unit_label
scale_amount = scale_amount
)
}
# Output final plot
Expand Down
3 changes: 1 addition & 2 deletions R/plot_recruitment.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ plot_recruitment <- function(
topic_label = gsub("plot_", "", utils::tail(as.character(sys.call()[[1]]), n = 1)),
fig_or_table = "figure",
dat = dat,
dir = figures_dir # ,
# unit_label = unit_label
dir = figures_dir
)
}
final
Expand Down
3 changes: 1 addition & 2 deletions R/plot_recruitment_deviations.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ plot_recruitment_deviations <- function(
topic_label = gsub("plot_", "", utils::tail(as.character(sys.call()[[1]]), n = 1)),
fig_or_table = "figure",
dat = selected_dat,
dir = figures_dir,
unit_label = ""
dir = figures_dir
)
}
final
Expand Down
3 changes: 1 addition & 2 deletions R/plot_selectivity.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ plot_selectivity <- function(
topic_label = gsub("plot_", "", utils::tail(as.character(sys.call()[[1]]), n = 1)),
fig_or_table = "figure",
dat = dat,
dir = figures_dir # ,
# unit_label = unit_label
dir = figures_dir
)
}
final
Expand Down
3 changes: 1 addition & 2 deletions R/plot_spawning_biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ plot_spawning_biomass <- function(
dat = rp_dat,
dir = figures_dir,
ref_line = ifelse(!is.null(names(ref_line)), names(ref_line), ref_line),
scale_amount = scale_amount,
unit_label = unit_label
scale_amount = scale_amount
)
}
# Output final plot
Expand Down
3 changes: 1 addition & 2 deletions R/plot_stock_recruitment.R
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ plot_stock_recruitment <- function(
topic_label = gsub("plot_", "", utils::tail(as.character(sys.call()[[1]]), n = 1)),
fig_or_table = "figure",
dat = dat,
dir = figures_dir # ,
# unit_label = unit_label
dir = figures_dir
)
}
final +
Expand Down
4 changes: 4 additions & 0 deletions R/process_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ process_table <- function(
id_group <- group
} else {
id_group <- index_variables[-grep("year|age|length_bin", index_variables)]
if (length(id_group) == 0) {
id_group <- NULL
}
}
cols <- index_variables[grep("year|age|length_bin", index_variables)]

Expand All @@ -397,6 +400,7 @@ process_table <- function(
} else if (!is.null(id_group)) {
if (length(id_group) > 1) {
cli::cli_alert_warning("Data contains >1 indexing variable. Selecting {id_group[1]}.")
id_group <- id_group[1]
}
if (length(id_group) > 0 && any(is.na(dat[[id_group]]))) {
dat <- dat |>
Expand Down
55 changes: 24 additions & 31 deletions R/save_all_plots.R

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 feel like there has to be an automated way to update this function whenever we add a new figure_* or table_*

Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@
#'
#' Default: ""
#'
#' @param biomass_unit_label String. Abbreviated biomass units
#'
#' Default: "mt"
#'
#' @param catch_unit_label String. Abbreviated catch units
#'
#' Default: "mt"
Expand Down Expand Up @@ -146,6 +142,7 @@ save_all_plots <- function(
figures_tables_dir = getwd(),
# imported from plot_biomass
ref_line = "msy",
biomass_unit_label = "mt",
biomass_scale_amount = 1,
# imported from plot_landings
landings_unit_label = "mt",
Expand All @@ -163,12 +160,11 @@ save_all_plots <- function(
biomass_at_age_unit_label = "mt",
# imported from plot_index
index_unit_label = "",
# imported from table_afsc_tier- add potential unique arguments after dev
# imported from table_bnc
biomass_unit_label = "mt",
# imported from table_biomass_abundance_catch
bac_unit_label = c("biomass" = "mt", "abundance" = "fish", "catch" = "mt"),

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 don't think this argument is in the roxygen documentation. Could you also change it to bnc?

# imported from plot_catch_comp
catch_unit_label = "mt",
catch_scale_amount = 1,
# imported from table_harvest_projection- add potential unique arguments after dev
# imported from table_index- zero unique arguments
# imported from table_landings- zero unique arguments
# imported from table_projections
Expand Down Expand Up @@ -469,29 +465,26 @@ save_all_plots <- function(
)

# tables
# tryCatch(
# {
# cli::cli_h2("table_bnc")
# table_bnc(
# dat,
# biomass_unit_label,
# catch_unit_label,
# spawning_biomass_label,
# make_rda = TRUE,
# tables_dir = figures_tables_dir
# ) # |>
# # suppressWarnings() |>
# # invisible()
# },
# error = function(e) {
# cli::cli_alert_danger("table_bnc failed to run.")
# cli::cli_alert("Tip: check that your arguments are correct.")
# cli::cli_li("biomass_unit_label = {biomass_unit_label}")
# cli::cli_li("catch_unit_label = {catch_unit_label}")
# cli::cli_li("spawning_biomass_label = {spawning_biomass_label}")
# print(e)
# }
# )
tryCatch(
{
cli::cli_h2("table_biomass_abundance_catch")
table_biomass_abundance_catch(
dat,
unit_label = bac_unit_label,
interactive = interactive,
make_rda = TRUE,
tables_dir = figures_tables_dir
) # |>
# suppressWarnings() |>
# invisible()
},
error = function(e) {
cli::cli_alert_danger("table_biomass_abundance_catch failed to run.")
cli::cli_alert("Tip: check that your arguments are correct.")
cli::cli_li("unit_label = {bac_unit_label}")
print(e)
}
)

tryCatch(
{
Expand Down
Loading
Loading