diff --git a/R/create_figures_doc.R b/R/create_figures_doc.R index 675f7a31..4f733d68 100644 --- a/R/create_figures_doc.R +++ b/R/create_figures_doc.R @@ -16,40 +16,62 @@ create_figures_doc <- function(resdir = NULL, model = c("SS3", "BAM", "ASAP", "AMAK", "WHAM"), year = NULL, subdir = NULL, - include_all = TRUE) { - model <- match.arg(model, several.ok = FALSE) + include_all = TRUE, + rda_dir = NULL) { - captions_alttext <- utils::read.csv( - system.file("resources", "captions_alttext.csv", package = "asar") - ) + model <- match.arg(model, several.ok = FALSE) if (include_all) { - # Create tables quarto doc - maybe should add this as separate fxn - same with figs + + # add header figures_doc <- paste0("## Figures \n \n") + + # add chunk that creates object as the directory of all rdas +figures_doc <- paste0( + figures_doc, + add_chunk( + paste0("rda_dir <- '", rda_dir, "/rda_files'"), + label = "set-rda-dir-figs", + eval = "true" + ), + "\n" + ) + # Recruitment ts figure + ## import plot, caption, alt text figures_doc <- paste0( figures_doc, add_chunk( - paste0("satf::plot_recruitment(dat = output)"), - label = "recruitment", - eval = "false", + paste0("# load rda +load(file.path(rda_dir, 'recruitment_figure.rda'))\n +# save rda with plot-specific name +recruitment_plot_rda <- rda\n +# remove generic rda object +rm(rda)\n +# save figure, caption, and alt text as separate objects +recruitment_plot <- recruitment_plot_rda$figure +recruitment_cap <- recruitment_plot_rda$cap +recruitment_alt_text <- recruitment_plot_rda$alt_text"), + label = "fig-recruitment-setup", + eval = "true" + ), + "\n" + ) + + ## add figure + figures_doc <- paste0( + figures_doc, + add_chunk( + paste0("recruitment_plot"), + label = "fig-recruitment-plot", + eval = "true", add_option = TRUE, chunk_op = c( glue::glue( - "fig-cap: '", - captions_alttext |> - dplyr::filter(label == "recruitment" & type == "figure") |> - dplyr::select(caption) |> - as.character(), - "'" + "fig-cap: recruitment_cap" ), glue::glue( - "fig-alt: '", - captions_alttext |> - dplyr::filter(label == "recruitment" & type == "figure") |> - dplyr::select(alt_text) |> - as.character(), - "'" + "fig-alt: recruitment_alt_text" ) ) ), @@ -57,31 +79,40 @@ create_figures_doc <- function(resdir = NULL, ) # SB figure - plot_code <- paste0( - "satf::plot_spawning_biomass(dat = output, ref_line = 'target', end_year = ", year, ")" + ## import plot, caption, alt text + figures_doc <- paste0( + figures_doc, + add_chunk( + paste0("# load rda +load(file.path(rda_dir, 'spawning_biomass_figure.rda'))\n +# save rda with plot-specific name +spawning_biomass_plot_rda <- rda\n +# remove generic rda object +rm(rda)\n +# save figure, caption, and alt text as separate objects +spawning_biomass_plot <- spawning_biomass_plot_rda$figure +spawning_biomass_cap <- spawning_biomass_plot_rda$cap +spawning_biomass_alt_text <- spawning_biomass_plot_rda$alt_text"), + label = "fig-spawning_biomass-setup", + eval = "true" + ), + "\n" ) + + ## add figure figures_doc <- paste0( figures_doc, - add_chunk(plot_code, - label = "spawn_bio", - eval = "false", + add_chunk( + paste0("spawning_biomass_plot"), + label = "fig-spawning_biomass-plot", + eval = "true", add_option = TRUE, chunk_op = c( glue::glue( - "fig-cap: '", - captions_alttext |> - dplyr::filter(label == "spawning_biomass" & type == "figure") |> - dplyr::select(caption) |> - as.character(), - "'" + "fig-cap: spawning_biomass_cap" ), glue::glue( - "fig-alt: '", - captions_alttext |> - dplyr::filter(label == "spawning_biomass" & type == "figure") |> - dplyr::select(alt_text) |> - as.character(), - "'" + "fig-alt: spawning_biomass_alt_text" ) ) ), @@ -89,148 +120,166 @@ create_figures_doc <- function(resdir = NULL, ) # B figure - plot_code <- paste0( - "satf::plot_biomass(dat = '", resdir, "/", model_results, - "', model = '", model, - "', ref_line = 'target', endyr = ", year, ")" + ## import plot, caption, alt text + figures_doc <- paste0( + figures_doc, + add_chunk( + paste0("# load rda +load(file.path(rda_dir, 'biomass_figure.rda'))\n +# save rda with plot-specific name +biomass_plot_rda <- rda\n +# remove generic rda object +rm(rda)\n +# save figure, caption, and alt text as separate objects +biomass_plot <- biomass_plot_rda$figure +biomass_cap <- biomass_plot_rda$cap +biomass_alt_text <- biomass_plot_rda$alt_text"), + label = "fig-biomass-setup", + eval = "true" + ), + "\n" ) - + ## add figure figures_doc <- paste0( figures_doc, - add_chunk(plot_code, - label = "fig-bio", - eval = "true", - add_option = TRUE, - chunk_op = c( - glue::glue( - "fig-cap: '", - captions_alttext |> - dplyr::filter(label == "tot_b" & type == "figure") |> - dplyr::select(caption) |> - as.character(), - "'" - ), - glue::glue( - "fig-alt: '", - captions_alttext |> - dplyr::filter(label == "tot_b" & type == "figure") |> - dplyr::select(alt_text) |> - as.character(), - "'" - ) - ) + add_chunk( + paste0("biomass_plot"), + label = "fig-biomass-plot", + eval = "true", + add_option = TRUE, + chunk_op = c( + glue::glue( + "fig-cap: biomass_cap" + ), + glue::glue( + "fig-alt: biomass_alt_text" + ) + ) ), "\n" ) # Landings figure - plot_code <- paste0( - "satf::plot_landings(dat = '", resdir, "/", model_results, - "', model = '", model, - "', ref_line = 'target', endyr = ", year, ")" + ## import plot, caption, alt text + figures_doc <- paste0( + figures_doc, + add_chunk( + paste0("# load rda +load(file.path(rda_dir, 'landings_figure.rda'))\n +# save rda with plot-specific name +landings_plot_rda <- rda\n +# remove generic rda object +rm(rda)\n +# save figure, caption, and alt text as separate objects +landings_plot <- landings_plot_rda$figure +landings_cap <- landings_plot_rda$cap +landings_alt_text <- landings_plot_rda$alt_text"), + label = "fig-landings-setup", + eval = "true" + ), + "\n" ) - + ## add figure figures_doc <- paste0( figures_doc, - add_chunk(plot_code, - label = "fig-landings", - eval = "true", - add_option = TRUE, - chunk_op = c( - glue::glue( - "fig-cap: '", - captions_alttext |> - dplyr::filter(label == "landings" & type == "figure") |> - dplyr::select(caption) |> - as.character(), - "'" - ), - glue::glue( - "fig-alt: '", - captions_alttext |> - dplyr::filter(label == "landings" & type == "figure") |> - dplyr::select(alt_text) |> - as.character(), - "'" - ) - ) + add_chunk( + paste0("landings_plot"), + label = "fig-landings-plot", + eval = "true", + add_option = TRUE, + chunk_op = c( + glue::glue( + "fig-cap: landings_cap" + ), + glue::glue( + "fig-alt: landings_alt_text" + ) + ) ), "\n" ) - - # Recruitment deviations figure - plot_code <- paste0( - "satf::plot_recruitment_deviations(dat = '", resdir, "/", model_results, - "', model = '", model, - "', ref_line = 'target', endyr = ", year, ")" + # recruitment deviations figure + ## import plot, caption, alt text + figures_doc <- paste0( + figures_doc, + add_chunk( + paste0("# load rda +load(file.path(rda_dir, 'recruitment_deviations_figure.rda'))\n +# save rda with plot-specific name +recruitment_deviations_plot_rda <- rda\n +# remove generic rda object +rm(rda)\n +# save figure, caption, and alt text as separate objects +recruitment_deviations_plot <- recruitment_deviations_plot_rda$figure +recruitment_deviations_cap <- recruitment_deviations_plot_rda$cap +recruitment_deviations_alt_text <- recruitment_deviations_plot_rda$alt_text"), + label = "fig-recruitment_deviations-setup", + eval = "true" + ), + "\n" ) - + ## add figure figures_doc <- paste0( figures_doc, - add_chunk(plot_code, - label = "fig-recruitment_deviations", - eval = "true", - add_option = TRUE, - chunk_op = c( - glue::glue( - "fig-cap: '", - captions_alttext |> - dplyr::filter(label == "recruitment_deviations" & type == "figure") |> - dplyr::select(caption) |> - as.character(), - "'" - ), - glue::glue( - "fig-alt: '", - captions_alttext |> - dplyr::filter(label == "recruitment_deviations" & type == "figure") |> - dplyr::select(alt_text) |> - as.character(), - "'" - ) - ) + add_chunk( + paste0("recruitment_deviations_plot"), + label = "fig-recruitment_deviations-plot", + eval = "true", + add_option = TRUE, + chunk_op = c( + glue::glue( + "fig-cap: recruitment_deviations_cap" + ), + glue::glue( + "fig-alt: recruitment_deviations_alt_text" + ) + ) ), "\n" ) - # spawning recruitment figure - plot_code <- paste0( - "satf::plot_spawning_recruitment(dat = '", resdir, "/", model_results, - "', model = '", model, - "', ref_line = 'target', endyr = ", year, ")" + ## import plot, caption, alt text + figures_doc <- paste0( + figures_doc, + add_chunk( + paste0("# load rda +load(file.path(rda_dir, 'est_stock_recruitment_figure.rda'))\n +# save rda with plot-specific name +spawning_recruitment_plot_rda <- rda\n +# remove generic rda object +rm(rda)\n +# save figure, caption, and alt text as separate objects +spawning_recruitment_plot <- spawning_recruitment_plot_rda$figure +spawning_recruitment_cap <- spawning_recruitment_plot_rda$cap +spawning_recruitment_alt_text <- spawning_recruitment_plot_rda$alt_text"), + label = "fig-spawning_recruitment-setup", + eval = "true" + ), + "\n" ) - + ## add figure figures_doc <- paste0( figures_doc, - add_chunk(plot_code, - label = "fig-spawn_recruitment", - eval = "true", - add_option = TRUE, - chunk_op = c( - glue::glue( - "fig-cap: '", - captions_alttext |> - dplyr::filter(label == "est_stock_recruitment" & type == "figure") |> - dplyr::select(caption) |> - as.character(), - "'" - ), - glue::glue( - "fig-alt: '", - captions_alttext |> - dplyr::filter(label == "est_stock_recruitment" & type == "figure") |> - dplyr::select(alt_text) |> - as.character(), - "'" - ) - ) + add_chunk( + paste0("spawning_recruitment_plot"), + label = "fig-spawning_recruitment-plot", + eval = "true", + add_option = TRUE, + chunk_op = c( + glue::glue( + "fig-cap: spawning_recruitment_cap" + ), + glue::glue( + "fig-alt: spawning_recruitment_alt_text" + ) + ) ), "\n" ) diff --git a/R/create_tables_doc.R b/R/create_tables_doc.R index a02805bd..d76cf843 100644 --- a/R/create_tables_doc.R +++ b/R/create_tables_doc.R @@ -1,5 +1,6 @@ #' Create Quarto Document of Tables #' +#' @inheritParams create_template #' @param resdir directory where the results file is located #' @param model_results name of the results file of assessment output #' @param model stock assessment model @@ -14,47 +15,66 @@ create_tables_doc <- function(resdir = NULL, model_results = NULL, model = c("SS3", "BAM", "ASAP", "AMAK", "WHAM"), subdir = NULL, - include_all = TRUE) { - model <- match.arg(model, several.ok = FALSE) + include_all = TRUE, + rda_dir = NULL) { - captions_alttext <- utils::read.csv( - system.file("resources", "captions_alttext.csv", package = "asar") - ) + model <- match.arg(model, several.ok = FALSE) if (include_all) { - # Create tables quarto doc - maybe should add this as separate fxn - same with figs + + # add header + tables_doc <- paste0("## Tables \n \n") + + # add chunk that creates object as the directory of all rdas tables_doc <- paste0( - "## Tables \n \n", - # Indices table + tables_doc, add_chunk( - paste0( - "satf::table_indices(dat = output)" + paste0("rda_dir <- '", rda_dir, "/rda_files'"), + label = "set-rda-dir-tbls", + eval = "false" ), - label = "indices", + "\n" + ) + + # Indices table + ## import table, caption + tables_doc <- paste0( + tables_doc, + add_chunk( + paste0("# load rda +load(file.path(rda_dir, 'indices_table.rda'))\n +# save rda with plot-specific name +indices_plot_rda <- rda\n +# remove generic rda object +rm(rda)\n +# save table, caption as separate objects +indices_table <- indices_table_rda$table +indices_cap <- indices_table_rda$cap"), + label = "tbl-indices-setup", + eval = "true" + ), + "\n" + ) + + ## add table + tables_doc <- paste0( + tables_doc, + add_chunk( + paste0("indices_table"), + label = "tbl-indices-plot", eval = "false", add_option = TRUE, chunk_op = c( glue::glue( - "tbl-cap: '", - captions_alttext |> - dplyr::filter(label == "indices" & type == "table") |> - dplyr::select(caption) |> - as.character(), - "'" + "tbl-cap: indices_cap" ) ) - ) + ), + "\n" ) # Add other tables follow the same above format - # tables_doc <- paste0("/n", - # tables_doc, - # add_chunk( - # paste0( - # "satf::table_XX()" - # ) - # ) - # ) + } else { # add option for only adding specified tables } diff --git a/R/create_template.R b/R/create_template.R index 1b0188eb..301b1371 100644 --- a/R/create_template.R +++ b/R/create_template.R @@ -100,7 +100,40 @@ #' using the image included in the project's repository. #' @param bib_file File path to a .bib file used for citing references in #' the report -#' +#' @param rda_dir The location of the folder containing .rda files +#' ("rda_files") already made with `satf`, or, if the user has not used +#' `satf` to make those .rda files already, rda_dir represents the location +#' that will contain .rda files in an "rda_files" folder. The folder would have +#' been made with `satf::exp_all_figs_tables()`, or by exporting files +#' by running individual `satf` figure- and table-generating functions. +#' If you have used `satf` to generate these .rda files, you can leave +#' the arguments below blank. +#' @inheritParams satf::plot_recruitment +#' @param make_rda This argument is automatically assessed based on the presence +#' or absence of .rda files and should be left blank. TRUE/FALSE; indicate +#' whether to produce an .rda file containing a list with the figure/table, +#' caption, and alternative text (if figure) for each figure and table. +#' @param ref_line An argument inherited from `satf::plot_spawning_biomass.R`. +#' A string specifying the type of reference you want to +#' compare spawning biomass to. The default is `"target"`, which looks for +#' `"spawning_biomass_target"` in the `"label"` column of `dat`. The actual +#' searching in `dat` is case agnostic and will work with either upper- or +#' lower-case letters but you must use one of the options specified in the +#' default list to ensure that the label on the figure looks correct +#' regardless of how it is specified in `dat`. +#' @param spawning_biomass_label An argument inherited from +#' `satf::plot_spawn_recruitment.R`. Units for spawning biomass. +#' @param recruitment_label An argument inherited from +#' `satf::plot_spawn_recruitment.R`. Units for recruitment. +#' @param ref_line_sb An argument with inherited from `satf::plot_spawning_biomass.R` +#' (under the parameter name `ref_line`, changed slightly to differentiate from +#' the ref_line indicated for `satf::plot_biomass.`) A string specifying the type of +#' reference you want to compare spawning biomass to. The default is `"target"`, +#' which looks for `"spawning_biomass_target"` in the `"label"` column of `dat`. +#' The actual searching in `dat` is case agnostic and will work with either upper- or +#' lower-case letters but you must use one of the options specified in the +#' default list to ensure that the label on the figure looks correct +#' regardless of how it is specified in `dat`. #' @return Create template and pull skeleton for a stock assessment report. #' Function builds a YAML specific to the region and utilizes current #' resources and workflows from different U.S. Fishery Science Centers. @@ -179,7 +212,18 @@ #' include_figures = TRUE, #' include_tables = TRUE, #' add_image = TRUE, -#' spp_image = "dir/containing/spp_image" +#' spp_image = "dir/containing/spp_image", +#' rda_dir = "C:/Users/Documents", +#' unit_label = "metric tons", +#' scale_amount = 1, +#' end_year = NULL, +#' n_projected_years = 10, +#' relative = FALSE, +#' make_rda = FALSE, +#' ref_line = c("target", "MSY", "msy", "unfished"), +#' spawning_biomass_label = "metric tons", +#' recruitment_label = "metric tons", +#' ref_line_sb = c("target", "MSY", "msy", "unfished") #' ) #' } #' @@ -217,7 +261,19 @@ create_template <- function( include_tables = TRUE, add_image = FALSE, spp_image = NULL, - bib_file = NULL) { + bib_file = NULL, + rda_dir = NULL, + unit_label = "metric tons", + scale_amount = 1, + end_year = NULL, + n_projected_years = 10, + relative = FALSE, + make_rda = FALSE, + ref_line = c("target", "MSY", "msy", "unfished"), + spawning_biomass_label = "metric tons", + recruitment_label = "metric tons", + ref_line_sb = c("target", "MSY", "msy", "unfished") + ) { # If analyst forgets to add year, default will be the current year report is being produced if (is.null(year)) { year <- format(as.POSIXct(Sys.Date(), format = "%YYYY-%mm-%dd"), "%Y") @@ -349,12 +405,23 @@ create_template <- function( # Create tables qmd if (include_tables) { if (!is.null(resdir) | !is.null(model_results) | !is.null(model)) { - create_tables_doc( - resdir = resdir, - model_results = model_results, - model = model, - subdir = subdir - ) + if (!is.null(rda_dir) & !is.null(end_year)){ + create_tables_doc( + resdir = resdir, + model_results = model_results, + model = model, + subdir = subdir, + rda_dir = rda_dir + ) + + } else { + tables_doc <- paste0( + "### Tables \n \n", + "Please refer to the `satf` package downloaded from remotes::install_github('nmfs-ost/satf') to add premade tables." + ) + utils::capture.output(cat(tables_doc), file = fs::path(subdir, "08_tables.qmd"), append = FALSE) + warning("Rda directory and/or arguments needed to create .rda files not defined.") + } } else { tables_doc <- paste0( "### Tables \n \n", @@ -362,15 +429,10 @@ create_template <- function( ) utils::capture.output(cat(tables_doc), file = fs::path(subdir, "08_tables.qmd"), append = FALSE) warning("Results file or model name not defined.") - } - } else { - tables_doc <- paste0( - "### Tables \n \n", - "Please refer to the `satf` package downloaded from remotes::install_github('nmfs-ost/satf') to add premade figures" - ) - utils::capture.output(cat(tables_doc), file = fs::path(subdir, "08_tables.qmd"), append = FALSE) + } } + # Rename model results for figures and tables files # TODO: check if this is needed once the tables and figures docs are reformatted # if (convert_output) { @@ -380,21 +442,32 @@ create_template <- function( # Create figures qmd if (include_figures) { if (!is.null(resdir) | !is.null(model_results) | !is.null(model)) { - create_figures_doc( - resdir = resdir, - model_results = model_results, - model = model, - subdir = subdir, - year = year - ) + if (!is.null(rda_dir) & !is.null(end_year)){ + create_figures_doc( + resdir = resdir, + model_results = model_results, + model = model, + subdir = subdir, + year = year, + rda_dir = rda_dir + ) + } else { + figures_doc <- paste0( + "### Figures \n \n", + "Please refer to the `satf` package downloaded from remotes::install_github('nmfs-ost/satf') to add premade figures." + ) + utils::capture.output(cat(figures_doc), file = fs::path(subdir, "09_figures.qmd"), append = FALSE) + warning("Rda directory and/or arguments needed to create .rda files not defined.") + } } else { - figures_doc <- paste0("## Figures \n") + figures_doc <- paste0( + "### Figures \n \n", + "Please refer to the `satf` package downloaded from remotes::install_github('nmfs-ost/satf') to add premade figures." + ) utils::capture.output(cat(figures_doc), file = fs::path(subdir, "09_figures.qmd"), append = FALSE) warning("Results file or model name not defined.") - } - } else { - figures_doc <- paste0("## Figures \n") - utils::capture.output(cat(figures_doc), file = fs::path(subdir, "09_figures.qmd"), append = FALSE) + + } } # Part I @@ -680,6 +753,33 @@ create_template <- function( resdir <- subdir } + # run satf::exp_all_figs_tables() if rda files not premade + if (!is.null(rda_dir) & !is.null(end_year)){ + + if(!dir.exists(file.path(rda_dir, "rda_files"))){ + + # load converted output + output <- utils::read.csv(paste0(resdir, "/", model_results)) + + # run satf::exp_all_figs_tables() to make rda files + satf::exp_all_figs_tables( + dat = output, + unit_label = unit_label, + scale_amount = scale_amount, + end_year = end_year, + n_projected_years = n_projected_years, + relative = relative, + make_rda = TRUE, + rda_dir = rda_dir, + ref_line = ref_line, + spawning_biomass_label = spawning_biomass_label, + recruitment_label = recruitment_label, + ref_line_sb = ref_line_sb + ) + } + } + + # print("_______Standardized output data________") # Add preamble diff --git a/man/create_figures_doc.Rd b/man/create_figures_doc.Rd index a6156e23..074ce763 100644 --- a/man/create_figures_doc.Rd +++ b/man/create_figures_doc.Rd @@ -10,7 +10,8 @@ create_figures_doc( model = c("SS3", "BAM", "ASAP", "AMAK", "WHAM"), year = NULL, subdir = NULL, - include_all = TRUE + include_all = TRUE, + rda_dir = NULL ) } \arguments{ @@ -34,6 +35,15 @@ the stock (e.g., "BAM", "SS3", "AMAK", "ASAP", etc.).} \item{include_all}{TRUE/FALSE; Option to include all default figures for a stock assessment report. Default is true.} + +\item{rda_dir}{The location of the folder containing .rda files +("rda_files") already made with \code{satf}, or, if the user has not used +\code{satf} to make those .rda files already, rda_dir represents the location +that will contain .rda files in an "rda_files" folder. The folder would have +been made with \code{satf::exp_all_figs_tables()}, or by exporting files +by running individual \code{satf} figure- and table-generating functions. +If you have used \code{satf} to generate these .rda files, you can leave +the arguments below blank.} } \value{ A quarto document with pre-loaded R chunk that adds the diff --git a/man/create_tables_doc.Rd b/man/create_tables_doc.Rd index ee7b50b7..583dfc4e 100644 --- a/man/create_tables_doc.Rd +++ b/man/create_tables_doc.Rd @@ -9,7 +9,8 @@ create_tables_doc( model_results = NULL, model = c("SS3", "BAM", "ASAP", "AMAK", "WHAM"), subdir = NULL, - include_all = TRUE + include_all = TRUE, + rda_dir = NULL ) } \arguments{ @@ -22,6 +23,15 @@ create_tables_doc( \item{subdir}{subdirectory where the assessment report template is being stored} \item{include_all}{include all default tables for a stock assessment report} + +\item{rda_dir}{The location of the folder containing .rda files +("rda_files") already made with \code{satf}, or, if the user has not used +\code{satf} to make those .rda files already, rda_dir represents the location +that will contain .rda files in an "rda_files" folder. The folder would have +been made with \code{satf::exp_all_figs_tables()}, or by exporting files +by running individual \code{satf} figure- and table-generating functions. +If you have used \code{satf} to generate these .rda files, you can leave +the arguments below blank.} } \value{ Create a quarto document as part of a stock assessment outline with diff --git a/man/create_template.Rd b/man/create_template.Rd index 98f2afb4..769362e1 100644 --- a/man/create_template.Rd +++ b/man/create_template.Rd @@ -38,7 +38,18 @@ create_template( include_tables = TRUE, add_image = FALSE, spp_image = NULL, - bib_file = NULL + bib_file = NULL, + rda_dir = NULL, + unit_label = "metric tons", + scale_amount = 1, + end_year = NULL, + n_projected_years = 10, + relative = FALSE, + make_rda = FALSE, + ref_line = c("target", "MSY", "msy", "unfished"), + spawning_biomass_label = "metric tons", + recruitment_label = "metric tons", + ref_line_sb = c("target", "MSY", "msy", "unfished") ) } \arguments{ @@ -171,6 +182,58 @@ using the image included in the project's repository.} \item{bib_file}{File path to a .bib file used for citing references in the report} + +\item{rda_dir}{The location of the folder containing .rda files +("rda_files") already made with \code{satf}, or, if the user has not used +\code{satf} to make those .rda files already, rda_dir represents the location +that will contain .rda files in an "rda_files" folder. The folder would have +been made with \code{satf::exp_all_figs_tables()}, or by exporting files +by running individual \code{satf} figure- and table-generating functions. +If you have used \code{satf} to generate these .rda files, you can leave +the arguments below blank.} + +\item{unit_label}{units for recruitment} + +\item{scale_amount}{indicate the exact amount of scale (i.e. 1000)} + +\item{end_year}{last year of assessment} + +\item{n_projected_years}{Number of years spawning biomass is projected for. +By default this number is set to 10} + +\item{relative}{A logical value specifying if the resulting figures should +be relative spawning biomass. The default is `FALSE`. `ref_line` indicates +which reference point to use.} + +\item{make_rda}{This argument is automatically assessed based on the presence +or absence of .rda files and should be left blank. TRUE/FALSE; indicate +whether to produce an .rda file containing a list with the figure/table, +caption, and alternative text (if figure) for each figure and table.} + +\item{ref_line}{An argument inherited from \code{satf::plot_spawning_biomass.R}. +A string specifying the type of reference you want to +compare spawning biomass to. The default is \code{"target"}, which looks for +\code{"spawning_biomass_target"} in the \code{"label"} column of \code{dat}. The actual +searching in \code{dat} is case agnostic and will work with either upper- or +lower-case letters but you must use one of the options specified in the +default list to ensure that the label on the figure looks correct +regardless of how it is specified in \code{dat}.} + +\item{spawning_biomass_label}{An argument inherited from +\code{satf::plot_spawn_recruitment.R}. Units for spawning biomass.} + +\item{recruitment_label}{An argument inherited from +\code{satf::plot_spawn_recruitment.R}. Units for recruitment.} + +\item{ref_line_sb}{An argument with inherited from \code{satf::plot_spawning_biomass.R} +(under the parameter name \code{ref_line}, changed slightly to differentiate from +the ref_line indicated for \code{satf::plot_biomass.}) A string specifying the type of +reference you want to compare spawning biomass to. The default is \code{"target"}, +which looks for \code{"spawning_biomass_target"} in the \code{"label"} column of \code{dat}. +The actual searching in \code{dat} is case agnostic and will work with either upper- or +lower-case letters but you must use one of the options specified in the +default list to ensure that the label on the figure looks correct +regardless of how it is specified in \code{dat}.} } \value{ Create template and pull skeleton for a stock assessment report. @@ -255,7 +318,18 @@ create_template( include_figures = TRUE, include_tables = TRUE, add_image = TRUE, - spp_image = "dir/containing/spp_image" + spp_image = "dir/containing/spp_image", + rda_dir = "C:/Users/Documents", + unit_label = "metric tons", + scale_amount = 1, + end_year = NULL, + n_projected_years = 10, + relative = FALSE, + make_rda = FALSE, + ref_line = c("target", "MSY", "msy", "unfished"), + spawning_biomass_label = "metric tons", + recruitment_label = "metric tons", + ref_line_sb = c("target", "MSY", "msy", "unfished") ) }