diff --git a/DESCRIPTION b/DESCRIPTION index ec9b52e0..91d966c4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -4,13 +4,10 @@ Version: 0.0.0.9000 Authors@R: person("Samantha", "Schiano", , "samantha.schiano@noaa.gov", role = c("aut", "cre"), comment = c(ORCID = "0009-0003-3744-6428")) -Description: Build a full or update stock assessment report for any stock - assessment model. Parameterization allows the user to call a - template based on their regional science center, species, area, ect. +Description: Build a full or update stock assessment report for any stock + assessment model. Parameterization allows the user to call a template + based on their regional science center, species, area, ect. License: MIT + file LICENSE -Encoding: UTF-8 -Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 Imports: dplyr, flextable, @@ -22,3 +19,6 @@ Imports: openxlsx, purrr, readr +Encoding: UTF-8 +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.3.1 diff --git a/R/add_section.R b/R/add_section.R index 7796314f..e4ed6236 100644 --- a/R/add_section.R +++ b/R/add_section.R @@ -20,28 +20,25 @@ #' @export #' #' @examples add_section(title = "Ecosystem Considerations", location = "after-discussion") - add_section <- function( title = NULL, location = NULL, - multi = FALSE -){ + multi = FALSE) { # Location options - # before-section - # after-section - # in-section (will always apend to the end of the section) + # before-section + # after-section + # in-section (will always apend to the end of the section) section_name <- forstringr::str_extract_part(location, "-", before = FALSE) - if(grepl("before-", location)){ + if (grepl("before-", location)) { } - if(grepl("in-", location)){ + if (grepl("in-", location)) { } - if(grepl("after-", location)){ + if (grepl("after-", location)) { } - } diff --git a/R/chunkr.R b/R/chunkr.R index f81181aa..544ec63b 100644 --- a/R/chunkr.R +++ b/R/chunkr.R @@ -19,18 +19,19 @@ chunkr <- function( warnings = "false", eval = "true", add_option = FALSE, - chunk_op = NULL){ + chunk_op = NULL) { chunk <- paste0( "```{r} \n", # Add output options "#| echo: ", echo, " \n", "#| warning: ", warnings, " \n", - "#| eval: ", eval, " \n") - if(add_option==TRUE){ - for (i in 1:length(chunk_op)) { - chunk <- paste0(chunk, "#| ", chunk_op[i], " \n") - } + "#| eval: ", eval, " \n" + ) + if (add_option == TRUE) { + for (i in 1:length(chunk_op)) { + chunk <- paste0(chunk, "#| ", chunk_op[i], " \n") } - chunk <- paste0(chunk, x, "\n", "``` \n") - return(chunk) + } + chunk <- paste0(chunk, x, "\n", "``` \n") + return(chunk) } diff --git a/R/convert_output.R b/R/convert_output.R index f97ae52a..d82dbd9b 100644 --- a/R/convert_output.R +++ b/R/convert_output.R @@ -14,32 +14,27 @@ #' adapt results among regional assessments. #' #' @examples -#' convert_output(output.file = "CumReport.sso", outdir = "~", model = 'ss', file.format = 'multi', multi.file = FALSE) +#' convert_output(output.file = "CumReport.sso", outdir = "~", model = "ss", file.format = "multi", multi.file = FALSE) #' #' @export #' convert_output <- function( output.file = NULL, outdir = NULL, - model = NULL){ - - if(model=="ss"){ + model = NULL) { + if (model == "ss") { # Fxn adapted from r4ss::SS_output - } - if(model=='bam'){ - dat <- dget(output.file) + if (model == "bam") { + dat <- dget(output.file) } - if(model=='asap'){ - + if (model == "asap") { # This is how Bai read the ASAP output # asap_output conversion written by Bai Li - asap_output <- dget(file.path(casedir, "output", subdir, paste("s", keep_sim_id[om_sim], sep=""), "asap3.rdat")) - setwd(file.path(casedir, "output", subdir, paste("s", keep_sim_id[om_sim], sep=""))) + asap_output <- dget(file.path(casedir, "output", subdir, paste("s", keep_sim_id[om_sim], sep = ""), "asap3.rdat")) + setwd(file.path(casedir, "output", subdir, paste("s", keep_sim_id[om_sim], sep = ""))) asap_std <- readRep("asap3", suffix = ".std") - } - } diff --git a/R/create_style_css.R b/R/create_style_css.R index 910898e4..2ca0646d 100644 --- a/R/create_style_css.R +++ b/R/create_style_css.R @@ -1,18 +1,17 @@ create_styles_css <- function( species = NULL, - savedir = NULL -){ - #Add species image to title + savedir = NULL) { + # Add species image to title spp_name <- sub(" ", "_", species) - spp_image <- list.files(path = here::here('inst', 'resources', 'spp_img'), pattern = spp_name) + spp_image <- list.files(path = here::here("inst", "resources", "spp_img"), pattern = spp_name) styles_css <- paste( ".quarto-title-block .quarto-title-banner {", "\n", - " ", "background-image: ", spp_image, ";", "\n", - " ", "background-size: 300px;", "\n", - " ", "background-position: left;", "\n", - " ", "background-repeat: no-repeat;", "\n", - " ", "padding-left: 10px;", "\n", - " ", "background-origin: content-box;", "\n", + " ", "background-image: ", spp_image, ";", "\n", + " ", "background-size: 300px;", "\n", + " ", "background-position: left;", "\n", + " ", "background-repeat: no-repeat;", "\n", + " ", "padding-left: 10px;", "\n", + " ", "background-origin: content-box;", "\n", "}", "\n" ) diff --git a/R/create_template.R b/R/create_template.R index 93b87b4c..caaa1ac2 100644 --- a/R/create_template.R +++ b/R/create_template.R @@ -41,18 +41,19 @@ #' each of the child documents should be edited separately. #' @export #' -#' @examples create_template(new_template = TRUE, format = "pdf", -#' office = "NEFSC", region = "GB", species = "Bluefish",spp_latin = "bluishfihesi", -#' year = 2024, author = c("John Snow", "Danny Phantom", "Patrick Star"), -#' include_affiliation = TRUE, parameters = TRUE, param_names = c("fleet1", "fleet2", "model"), -#' param_values = c("Commercial", "Recreational", "Woods Hole Assessment Model"), -#' type = "RT") - +#' @examples create_template( +#' new_template = TRUE, format = "pdf", +#' office = "NEFSC", region = "GB", species = "Bluefish", spp_latin = "bluishfihesi", +#' year = 2024, author = c("John Snow", "Danny Phantom", "Patrick Star"), +#' include_affiliation = TRUE, parameters = TRUE, param_names = c("fleet1", "fleet2", "model"), +#' param_values = c("Commercial", "Recreational", "Woods Hole Assessment Model"), +#' type = "RT" +#' ) create_template <- function( new_template = TRUE, tempdir = here::here(), - format = c("pdf","docx","html", NULL), - office = c("AFSC","PIFSC","NEFSC","NWFSC","SEFSC","SWFSC"), + format = c("pdf", "docx", "html", NULL), + office = c("AFSC", "PIFSC", "NEFSC", "NWFSC", "SEFSC", "SWFSC"), region = NULL, complex = "NO", species = NULL, @@ -73,338 +74,371 @@ create_template <- function( secdir = NULL, new_section = NULL, section_location = NULL, - type = c("OA","UP","RT","FULL","MT"), + type = c("OA", "UP", "RT", "FULL", "MT"), prev_year = NULL, custom = FALSE, - custom_sections = NULL - ){ - + custom_sections = NULL) { # 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") + if (is.null(year)) { + year <- format(as.POSIXct(Sys.Date(), format = "%YYYY-%mm-%dd"), "%Y") } # Name report - report_name <- paste0(type, - "_") - if(!is.null(region)){ - report_name <- paste0(report_name, - gsub("(\\b[A-Z])[^A-Z]+", "\\1", region)) + report_name <- paste0( + type, + "_" + ) + if (!is.null(region)) { + report_name <- paste0( + report_name, + gsub("(\\b[A-Z])[^A-Z]+", "\\1", region) + ) } - report_name <- paste0(report_name, "_", - gsub(" ", "_", species), - "_skeleton.qmd") + report_name <- paste0( + report_name, "_", + gsub(" ", "_", species), + "_skeleton.qmd" + ) # Select parameter from list format <- match.arg(format, several.ok = FALSE) office <- match.arg(office, several.ok = FALSE) type <- match.arg(type, several.ok = FALSE) - if(!is.null(region)){ - subdir <- here::here('inst', 'templates', 'archive', office, species, region, year) - subdir <- system.file('inst', 'templates', 'archive', office, species, region, year, package = 'ASAR') + if (!is.null(region)) { + subdir <- here::here("inst", "templates", "archive", office, species, region, year) + subdir <- system.file("inst", "templates", "archive", office, species, region, year, package = "ASAR") } else { - subdir <- here::here('inst', 'templates', 'archive', office, species, year) + subdir <- here::here("inst", "templates", "archive", office, species, year) } # Always creating new directory for each assessment since they will each change # Allow NOAA to keep a record of each assessment file # These will need to be cataloged into a cloud system somehow - if(!dir.exists(here::here('inst','templates', 'archive', office, species))){ - dir.create(here::here('inst','templates', 'archive', office, species)) + if (!dir.exists(here::here("inst", "templates", "archive", office, species))) { + dir.create(here::here("inst", "templates", "archive", office, species)) } - if(!is.null(region)){ - if(!dir.exists(here::here('inst','templates', 'archive', office, species, region))){ - dir.create(here::here('inst','templates', 'archive', office, species, region)) + if (!is.null(region)) { + if (!dir.exists(here::here("inst", "templates", "archive", office, species, region))) { + dir.create(here::here("inst", "templates", "archive", office, species, region)) } # Create new folder for current year - if(!dir.exists(here::here('inst','templates', 'archive', office, species, region, year))){ - dir.create(here::here('inst','templates', 'archive', office, species, region, year)) + if (!dir.exists(here::here("inst", "templates", "archive", office, species, region, year))) { + dir.create(here::here("inst", "templates", "archive", office, species, region, year)) } } else { # Create new folder for current year - if(!dir.exists(here::here('inst','templates', 'archive', office, species, year))){ - dir.create(here::here('inst','templates', 'archive', office, species, year)) + if (!dir.exists(here::here("inst", "templates", "archive", office, species, year))) { + dir.create(here::here("inst", "templates", "archive", office, species, year)) } } - if(new_template==TRUE){ - # Pull skeleton for sections - current_folder <- here::here('inst','templates','skeleton') - new_folder <- subdir - files_to_copy <- list.files(current_folder) - file.copy(file.path(current_folder, files_to_copy), new_folder) - - # Part I - # Create a report template file to render for the region and species - # Create YAML header for document - # Write title based on report type and region - if(alt_title==FALSE){ - title <- write_title(office = office, species = species, spp_latin = spp_latin, region = region, type = type) - } else if (alt_title==TRUE){ - if(!exists(title)){ - stop("Alternate title not defined. Please define an alternative title in the parameter 'title'.") - } else { - title <- paste(title) + if (new_template == TRUE) { + # Pull skeleton for sections + current_folder <- here::here("inst", "templates", "skeleton") + new_folder <- subdir + files_to_copy <- list.files(current_folder) + file.copy(file.path(current_folder, files_to_copy), new_folder) + + # Part I + # Create a report template file to render for the region and species + # Create YAML header for document + # Write title based on report type and region + if (alt_title == FALSE) { + title <- write_title(office = office, species = species, spp_latin = spp_latin, region = region, type = type) + } else if (alt_title == TRUE) { + if (!exists(title)) { + stop("Alternate title not defined. Please define an alternative title in the parameter 'title'.") + } else { + title <- paste(title) + } } - } - # Pull authors and affiliations from national db - # Parameters to add authorship to YAML - # Read authorship file - authors <- utils::read.csv(here::here('inst', 'resources', 'authorship.csv')) |> - dplyr::mutate(mi = dplyr::case_when(mi=="" ~ NA, - TRUE ~ mi), - name = dplyr::case_when(is.na(mi) ~ paste0(first," ", last), - TRUE ~ paste(first, mi, last, sep = " "))) |> - dplyr::select(name, office) |> - dplyr::filter(name %in% author) - if(include_affiliation==TRUE){ - affil <- read.csv(here::here('inst', 'resources', 'affiliation_info.csv')) - } - author_list <- list() - - if(include_affiliation==TRUE & simple_affiliation==FALSE){ - for(i in 1:nrow(authors)){ - auth <- authors[i,] - aff <- affil |> - dplyr::filter(affiliation==auth$office) - paste0(" ", "- name: ", "'", auth$name, "'", "\n", - " ", " ", "affiliations:", "\n", - " ", " ", " ", "- name: ", "'", "NOAA Fisheries ", aff$name, "'", "\n", - " ", " ", " ", " ", "address: ", "'", aff$address, "'","\n", - " ", " ", " ", " ", "city: ", "'", aff$city, "'","\n", - " ", " ", " ", " ", "state: ", "'", aff$state, "'","\n", - " ", " ", " ", " ", "postal-code: ", "'", aff$postal.code, "'","\n" - # sep = " " - ) -> author_list[[i]] - } - } else if(include_affiliation==TRUE & simple_affiliation==TRUE){ - for(i in 1:nrow(authors)){ - auth <- authors[i,] - aff <- affil |> - dplyr::filter(affiliation==auth$office) - paste0(" ", "- name: ", "'", auth$name, "'", "\n", - " ", " ", "affiliations: ", "'", aff$name, "'", "\n" - ) -> author_list[[i]] - } - } else { - for(i in 1:nrow(authors)){ - auth <- authors[i,] - paste0(" ", "- ", "'", auth$name, "'", "\n") -> author_list[[i]] + # Pull authors and affiliations from national db + # Parameters to add authorship to YAML + # Read authorship file + authors <- utils::read.csv(here::here("inst", "resources", "authorship.csv")) |> + dplyr::mutate( + mi = dplyr::case_when( + mi == "" ~ NA, + TRUE ~ mi + ), + name = dplyr::case_when( + is.na(mi) ~ paste0(first, " ", last), + TRUE ~ paste(first, mi, last, sep = " ") + ) + ) |> + dplyr::select(name, office) |> + dplyr::filter(name %in% author) + if (include_affiliation == TRUE) { + affil <- read.csv(here::here("inst", "resources", "affiliation_info.csv")) } - } - - # Creating YAML - yaml <- paste0( - # start YAML notation - "---", "\n", - - # Tile - "title: ", "'", title, "'", "\n", - - # Author - "author:", "\n") - # Add authors - add_authors <- NULL - for (i in 1:length(author_list)) { - toad <- paste(author_list[[i]], sep =",") - add_authors <- paste0(add_authors, toad) # -> add_authors - } - yaml <- paste0(yaml, add_authors) - - # Add other parts - yaml <- paste0(yaml, - # Date - "date: today", "\n" - ) - - # Formating - - if(include_affiliation==TRUE){ - - yaml <- paste(yaml, "format: \n", - " " , format, ": \n", - " ", " ", "keep-tex: ", "true \n", - " " , " ", "template-partials: \n", - " ", " ", " ", " - graphics.tex \n", - " ", " ", " ", " - title.tex \n", - " ", " ", "include-in-header: \n", - " ", " ", " ", " - in-header.tex \n", - sep = "") - - } else if(include_affiliation==FALSE){ - - yaml <- paste0(yaml, "format: \n", - " ", format, ": \n", - " ", " ", "template-partials: \n", - " ", " ", " ", "- sadraft.tex \n", - " ", " ", "keep-tex: true \n" - ) - - } - - # Parameters - # office, region, and species are default parameters - yaml <- paste0(yaml, "params:", "\n", - " ", " ", "office: ", "'", office, "'", "\n", - " ", " ", "species: ", "'", species, "'", "\n", - " ", " ", "spp_latin: ", "'", spp_latin, "'", "\n" - ) - if(!is.null(region)){ - yaml <- paste0(yaml, " ", " ", "region: ", "'", region, "'", "\n") - } - if(parameters==TRUE){ - if(!is.null(param_names) & !is.null(param_values)){ - add_params <- NULL - for (i in 1:length(param_names)) { - toad <- paste(" ", " ", param_names[i], ": ", "'",param_values[i], "'", "\n", sep="") - add_params <- paste0(add_params, toad) + author_list <- list() + + if (include_affiliation == TRUE & simple_affiliation == FALSE) { + for (i in 1:nrow(authors)) { + auth <- authors[i, ] + aff <- affil |> + dplyr::filter(affiliation == auth$office) + paste0( + " ", "- name: ", "'", auth$name, "'", "\n", + " ", " ", "affiliations:", "\n", + " ", " ", " ", "- name: ", "'", "NOAA Fisheries ", aff$name, "'", "\n", + " ", " ", " ", " ", "address: ", "'", aff$address, "'", "\n", + " ", " ", " ", " ", "city: ", "'", aff$city, "'", "\n", + " ", " ", " ", " ", "state: ", "'", aff$state, "'", "\n", + " ", " ", " ", " ", "postal-code: ", "'", aff$postal.code, "'", "\n" + # sep = " " + ) -> author_list[[i]] + } + } else if (include_affiliation == TRUE & simple_affiliation == TRUE) { + for (i in 1:nrow(authors)) { + auth <- authors[i, ] + aff <- affil |> + dplyr::filter(affiliation == auth$office) + paste0( + " ", "- name: ", "'", auth$name, "'", "\n", + " ", " ", "affiliations: ", "'", aff$name, "'", "\n" + ) -> author_list[[i]] } } else { - print("Please define parameter names (param_names) and values (param_values).") + for (i in 1:nrow(authors)) { + auth <- authors[i, ] + paste0(" ", "- ", "'", auth$name, "'", "\n") -> author_list[[i]] + } } - yaml <- paste0(yaml, add_params) - } - - # Add style guide - create_style_css(species = species, savedir = subdir) - - yaml <- paste0(yaml, - "css: styles.css", "\n") - - # Close yaml - yaml <- paste0(yaml, "---") - - print("__________Built YAML Header______________") - # yaml_save <- capture.output(cat(yaml)) - # cat(yaml, file = here('template','yaml_header.qmd')) - - # Add chunk to load in assessment data - ass_output <- chunkr( - "convert_output( output.file=", model_results, ", model=", model, ")", - eval = "false" # set false for testing this function in the template for now - ) - - # print("_______Standardized output data________") - - # Add page for citation of assessment report - citation <- generate_citation(author = author, - title = title, - year = year, - office = office) + # Creating YAML + yaml <- paste0( + # start YAML notation + "---", "\n", + + # Tile + "title: ", "'", title, "'", "\n", + + # Author + "author:", "\n" + ) + # Add authors + add_authors <- NULL + for (i in 1:length(author_list)) { + toad <- paste(author_list[[i]], sep = ",") + add_authors <- paste0(add_authors, toad) # -> add_authors + } + yaml <- paste0(yaml, add_authors) + + # Add other parts + yaml <- paste0( + yaml, + # Date + "date: today", "\n" + ) + + # Formating + + if (include_affiliation == TRUE) { + yaml <- paste(yaml, "format: \n", + " ", format, ": \n", + " ", " ", "keep-tex: ", "true \n", + " ", " ", "template-partials: \n", + " ", " ", " ", " - graphics.tex \n", + " ", " ", " ", " - title.tex \n", + " ", " ", "include-in-header: \n", + " ", " ", " ", " - in-header.tex \n", + sep = "" + ) + } else if (include_affiliation == FALSE) { + yaml <- paste0( + yaml, "format: \n", + " ", format, ": \n", + " ", " ", "template-partials: \n", + " ", " ", " ", "- sadraft.tex \n", + " ", " ", "keep-tex: true \n" + ) + } - print("_______Generate Report Citaiton________") + # Parameters + # office, region, and species are default parameters + yaml <- paste0( + yaml, "params:", "\n", + " ", " ", "office: ", "'", office, "'", "\n", + " ", " ", "species: ", "'", species, "'", "\n", + " ", " ", "spp_latin: ", "'", spp_latin, "'", "\n" + ) + if (!is.null(region)) { + yaml <- paste0(yaml, " ", " ", "region: ", "'", region, "'", "\n") + } + if (parameters == TRUE) { + if (!is.null(param_names) & !is.null(param_values)) { + add_params <- NULL + for (i in 1:length(param_names)) { + toad <- paste(" ", " ", param_names[i], ": ", "'", param_values[i], "'", "\n", sep = "") + add_params <- paste0(add_params, toad) + } + } else { + print("Please define parameter names (param_names) and values (param_values).") + } - # Create report template + yaml <- paste0(yaml, add_params) + } - if(custom==FALSE){ - if(type=="OA" | type=="UP" | type=="MT"){ - sections <- paste_child( - c("01_executive_summary.qmd", - "02_introduction.qmd"), - label = c("executive_summary", - "introduction") + # Add style guide + create_style_css(species = species, savedir = subdir) + + yaml <- paste0( + yaml, + "css: styles.css", "\n" + ) + + # Close yaml + yaml <- paste0(yaml, "---") + + print("__________Built YAML Header______________") + # yaml_save <- capture.output(cat(yaml)) + # cat(yaml, file = here('template','yaml_header.qmd')) + + # Add chunk to load in assessment data + ass_output <- chunkr( + "convert_output( output.file=", model_results, ", model=", model, ")", + eval = "false" # set false for testing this function in the template for now + ) + + # print("_______Standardized output data________") + + # Add page for citation of assessment report + citation <- generate_citation( + author = author, + title = title, + year = year, + office = office + ) + + print("_______Generate Report Citaiton________") + + # Create report template + + if (custom == FALSE) { + if (type == "OA" | type == "UP" | type == "MT") { + sections <- paste_child( + c( + "01_executive_summary.qmd", + "02_introduction.qmd" + ), + label = c( + "executive_summary", + "introduction" + ) ) - } else if (type=="RT" | type=="FULL"){ - sections <- paste_child(c( - "01_executive_summary.qmd", - "02_introduction.qmd", - "03_data.qmd", - "04_model.qmd", - "05_results.qmd", - "06_discussion.qmd", - "07_acknowledgements.qmd", - "08_references.qmd", - "09_tables.qmd", - "10_figures.qmd", - "11_appendix.qmd" - ), - label = c("executive_summary", - "introduction", - "data", - "model", - "results", - "discussion", - "acknowlesgements", - "references", - "tables", - "figures", - "appendix" - ) + } else if (type == "RT" | type == "FULL") { + sections <- paste_child( + c( + "01_executive_summary.qmd", + "02_introduction.qmd", + "03_data.qmd", + "04_model.qmd", + "05_results.qmd", + "06_discussion.qmd", + "07_acknowledgements.qmd", + "08_references.qmd", + "09_tables.qmd", + "10_figures.qmd", + "11_appendix.qmd" + ), + label = c( + "executive_summary", + "introduction", + "data", + "model", + "results", + "discussion", + "acknowlesgements", + "references", + "tables", + "figures", + "appendix" + ) ) - } else { - print("Type of assessment report is not defined") - } - } else { - # Option for building custom template - # Create custom template from existing skeleton sections - if(add_section==FALSE){ - section_list <- list() - for(i in 1:length(custom_sections)){ - grep( - x = list.files(here::here('inst', 'templates', 'skeleton')), - pattern = custom_sections[i], - value = TRUE) -> section_list[i] + } else { + print("Type of assessment report is not defined") } - sections <- paste_child(section_list, - label = custom_sections) } else { - # Create custom template using existing sections and new sections from analyst - # Add sections from package options - if(is.null(customs_sections)){stop("Custom sectioning not defined.")} - section_list <- list() - if(custom==TRUE){ - for(i in 1:length(custom_sections)){ + # Option for building custom template + # Create custom template from existing skeleton sections + if (add_section == FALSE) { + section_list <- list() + for (i in 1:length(custom_sections)) { grep( - x = list.files(here::here('inst', 'templates', 'skeleton')), + x = list.files(here::here("inst", "templates", "skeleton")), pattern = custom_sections[i], - value = TRUE) -> section_list[i] + value = TRUE + ) -> section_list[i] + } + sections <- paste_child(section_list, + label = custom_sections + ) + } else { + # Create custom template using existing sections and new sections from analyst + # Add sections from package options + if (is.null(customs_sections)) { + stop("Custom sectioning not defined.") + } + section_list <- list() + if (custom == TRUE) { + for (i in 1:length(custom_sections)) { + grep( + x = list.files(here::here("inst", "templates", "skeleton")), + pattern = custom_sections[i], + value = TRUE + ) -> section_list[i] + } } - } # Add new sections - if(is.null(new_section) | is.null(section_location)){stop("New sections and locations not defined.")} + if (is.null(new_section) | is.null(section_location)) { + stop("New sections and locations not defined.") + } for (i in 1:length(new_section)) { add_sec_new[i] <- paste0(secdir, "/", new_section[i]) } - append(section_list, add_sec_new) + append(section_list, add_sec_new) sections <- paste_child(section_list, - label = section_list) + label = section_list + ) + } } - } - - # Combine template sections - report_template <- paste(yaml, - ass_output, - citation, - sections, - sep = "\n") - print("___Created desired report template______") + # Combine template sections + report_template <- paste(yaml, + ass_output, + citation, + sections, + sep = "\n" + ) - # Save template as .qmd to render - utils::capture.output(cat(report_template), file = paste0(subdir, "/", report_name), append = FALSE) + print("___Created desired report template______") - print(cat(paste0("Saved report template in directory: ", subdir, "\n", - "To proceeed, please edit sections within the report template in order to produce a completed stock assessment report."))) + # Save template as .qmd to render + utils::capture.output(cat(report_template), file = paste0(subdir, "/", report_name), append = FALSE) + print(cat(paste0( + "Saved report template in directory: ", subdir, "\n", + "To proceeed, please edit sections within the report template in order to produce a completed stock assessment report." + ))) } else { # Copy old template and rename for new year # Create copy of previous assessment - if(!is.null(region)){ - olddir <- here::here('inst', 'templates', 'archive', office, species, region, prev_year) - invisible(file.copy(file.path(here::here('inst', 'templates', 'archive', office, species, region, prev_year), list.files(olddir)), subdir, recursive = FALSE)) + if (!is.null(region)) { + olddir <- here::here("inst", "templates", "archive", office, species, region, prev_year) + invisible(file.copy(file.path(here::here("inst", "templates", "archive", office, species, region, prev_year), list.files(olddir)), subdir, recursive = FALSE)) } else { - olddir <- here::here('inst', 'templates', 'archive', office, species, prev_year) - invisible(file.copy(file.path(here::here('inst', 'templates', 'archive', office, species, prev_year), list.files(olddir)), subdir, recursive = FALSE)) + olddir <- here::here("inst", "templates", "archive", office, species, prev_year) + invisible(file.copy(file.path(here::here("inst", "templates", "archive", office, species, prev_year), list.files(olddir)), subdir, recursive = FALSE)) } # Open previous skeleton skeleton <- list.files(subdir, pattern = "skeleton.qmd") - file.show(file.path(paste0(subdir,"/",report_name))) # this opens the new file, but also restarts the session + file.show(file.path(paste0(subdir, "/", report_name))) # this opens the new file, but also restarts the session } } diff --git a/R/export_object.R b/R/export_object.R index 6df5ae40..f0047d6a 100644 --- a/R/export_object.R +++ b/R/export_object.R @@ -12,50 +12,41 @@ #' @export #' #' @examples -#' source <- c("NMFS Groundfish Survey","","U.S. Trawl Fisheries", "", "") -#' data <- c("Survey biomass","Age Composition","Catch","Age Composition","Length Composition") -#' years <- c("1984-1999 (triennial), 2001-2013 (biennial)","1984, 1987, 1990, 1993, 1996, 1999, 2003, 2005, 2007, 2009, 2011","1961-2013", "1990,1998-2002, 2004, 2005, 2006, 2008, 2010","1963-1977, 1991-1997") +#' source <- c("NMFS Groundfish Survey", "", "U.S. Trawl Fisheries", "", "") +#' data <- c("Survey biomass", "Age Composition", "Catch", "Age Composition", "Length Composition") +#' years <- c("1984-1999 (triennial), 2001-2013 (biennial)", "1984, 1987, 1990, 1993, 1996, 1999, 2003, 2005, 2007, 2009, 2011", "1961-2013", "1990,1998-2002, 2004, 2005, 2006, 2008, 2010", "1963-1977, 1991-1997") #' test_obj <- data.frame(source, data, years) #' #' export_object(object = test_obj, file_format = "csv") #' - - export_object <- function( object = NULL, - file_format = "docx"){ - - if(file_format=="pdf"){ - - grDevices::pdf(file = paste0(here::here('exported'),"/",sprintf(deparse(substitute(object))),".pdf")) # pdf fxn in base r + file_format = "docx") { + if (file_format == "pdf") { + grDevices::pdf(file = paste0(here::here("exported"), "/", sprintf(deparse(substitute(object))), ".pdf")) # pdf fxn in base r gridExtra::grid.table(object) grDevices::dev.off() # Doesn't fit to page - - } else if(file_format=="docx"){ - + } else if (file_format == "docx") { doc_exp <- officer::read_docx() doc_exp <- officer::body_add_table(object) print(doc_exp, - target = paste0(here::here('exported'),"/", sprintf(deparse(substitute(object))),".docx")) # %>% invisible() - - } else if(file_format=="xlsx"){ - + target = paste0(here::here("exported"), "/", sprintf(deparse(substitute(object))), ".docx") + ) # %>% invisible() + } else if (file_format == "xlsx") { openxlsx::write.xlsx(object, - file = paste0(here::here('exported'),"/", sprintf(deparse(substitute(object))), ".xlsx"), - overwrite = FALSE) - - } else if(file_format=="csv"){ - + file = paste0(here::here("exported"), "/", sprintf(deparse(substitute(object))), ".xlsx"), + overwrite = FALSE + ) + } else if (file_format == "csv") { utils::write.csv(object, - file = paste0(here::here('exported'),"/", sprintf(deparse(substitute(object))), ".csv"), - row.names = FALSE) - - } else if(file_format=="rdata"){ - + file = paste0(here::here("exported"), "/", sprintf(deparse(substitute(object))), ".csv"), + row.names = FALSE + ) + } else if (file_format == "rdata") { save(object, - file = paste0(here::here('exported'), "/", sprintf(deparse(substitute(object))), ".Rdata")) - + file = paste0(here::here("exported"), "/", sprintf(deparse(substitute(object))), ".Rdata") + ) } else { stop("File format is not currently available for output. Please open an issue in the GitHub repository to request the addition.") } diff --git a/R/generate_citation.R b/R/generate_citation.R index c64c6d79..316908ef 100644 --- a/R/generate_citation.R +++ b/R/generate_citation.R @@ -9,79 +9,82 @@ #' the stock assessment report generated in the ASAR package. #' @export #' -#' @examples generate_citation(title = "SA Report for Jellyfish", -#' author = c("John Snow", "Danny Phantom", "Patrick Star"), -#' year = 2024, office = "NEFSC") +#' @examples generate_citation( +#' title = "SA Report for Jellyfish", +#' author = c("John Snow", "Danny Phantom", "Patrick Star"), +#' year = 2024, office = "NEFSC" +#' ) #' generate_citation <- function( author = NULL, title = NULL, year = NULL, - office = NULL - ){ - - if(office %in% c('NEFSC','SEFSC','NWFSC','SWFSC','PIFSC','AFSC')){ + office = NULL) { + if (office %in% c("NEFSC", "SEFSC", "NWFSC", "SWFSC", "PIFSC", "AFSC")) { off_title <- "NOAA Fisheries Science Center" } office1 <- office - office_loc <- utils::read.csv(here::here('inst', 'resources', 'affiliation_info.csv')) |> - dplyr::filter(affiliation==office1) + office_loc <- utils::read.csv(here::here("inst", "resources", "affiliation_info.csv")) |> + dplyr::filter(affiliation == office1) # Check - if(nrow(office_loc)>1){stop("There is more than one office being selected in this function. Please review 'generate_ciation.R'.")} + if (nrow(office_loc) > 1) { + stop("There is more than one office being selected in this function. Please review 'generate_ciation.R'.") + } loc_city <- office_loc$city loc_state <- office_loc$state # Author naming convention formatting - if(length(author)>1){ + if (length(author) > 1) { author1 <- unlist(strsplit(author[1], split = " ")) author1 <- paste0( - ifelse(length(author1)==3, author1[3], author1[2]), ", ", + ifelse(length(author1) == 3, author1[3], author1[2]), ", ", substring(author1[1], 1, 1), ".", - ifelse(length(author1)==3, author1[2], "") + ifelse(length(author1) == 3, author1[2], "") ) - author_list <- paste0(author1) - for(i in 2:length(author)){ + author_list <- paste0(author1) + for (i in 2:length(author)) { auth_extract <- unlist(strsplit(author[i], split = " ")) auth_extract2 <- paste0( substring(auth_extract[1], 1, 1), ".", - ifelse(length(auth_extract)==3, auth_extract[2], ""), " ", - ifelse(length(auth_extract)==3, auth_extract[3], auth_extract[2]) - ) + ifelse(length(auth_extract) == 3, auth_extract[2], ""), " ", + ifelse(length(auth_extract) == 3, auth_extract[3], auth_extract[2]) + ) author_list <- paste0(author_list, ", ", auth_extract2) } } else { author_spl <- unlist(strsplit(author, split = " ")) author_list <- paste0( - ifelse(length(author_spl)==3, author_spl[3], author_spl[2]), ", ", + ifelse(length(author_spl) == 3, author_spl[3], author_spl[2]), ", ", substring(author_spl[[1]][1], 1, 1), ".", - ifelse(length(author_spl)==3, author_spl[2], "") + ifelse(length(author_spl) == 3, author_spl[2], "") ) } # Create citation string - if(office!="SEFSC"){ - cit <- paste0("{{< pagebreak >}} \n", - "\n", - "Please cite this publication as \n", - "\n", - author_list, ". ", year, ". ", - title, ". ", off_title, ", ", - loc_city, ", ", loc_state, ". " - ) + if (office != "SEFSC") { + cit <- paste0( + "{{< pagebreak >}} \n", + "\n", + "Please cite this publication as \n", + "\n", + author_list, ". ", year, ". ", + title, ". ", off_title, ", ", + loc_city, ", ", loc_state, ". " + ) } else { - cit <- paste0("'{{< pagebreak >}}' \n", - "\n", - "Please cite this publication as \n", - "\n", - "SEDAR. ", year, ". ", title, - "SEDAR, North Charleston SC. XXpp. ", - "available online at: http://sedarweb.org/" - ) + cit <- paste0( + "'{{< pagebreak >}}' \n", + "\n", + "Please cite this publication as \n", + "\n", + "SEDAR. ", year, ". ", title, + "SEDAR, North Charleston SC. XXpp. ", + "available online at: http://sedarweb.org/" + ) } # Add citation as .qmd to add into template return(cit) - } diff --git a/R/paste_child.R b/R/paste_child.R index 9ad1104c..172c6235 100644 --- a/R/paste_child.R +++ b/R/paste_child.R @@ -8,11 +8,10 @@ #' @export #' #' @examples paste_child("test_quarto.qmd", label = "test_doc") - paste_child <- function(x, - label = NULL){ + label = NULL) { child <- c() - for(i in 1:length(x)){ + for (i in 1:length(x)) { sec_num <- x[i] child_loop <- paste0( "\n", @@ -25,7 +24,7 @@ paste_child <- function(x, "a <- knitr::knit_child(", "'", sec_num, "'", ", quiet = TRUE)", "\n", "cat(a, sep = '\\n')", "\n", "```", "\n" - ) + ) child <- paste(child, child_loop, sep = "\n {{< pagebreak >}} \n") } return(child) diff --git a/R/report_format.R b/R/report_format.R index 62ff29bf..33a2f071 100644 --- a/R/report_format.R +++ b/R/report_format.R @@ -1,41 +1,41 @@ report_format <- function( type = NULL, - office = NULL){ + office = NULL) { # This may need to be changed bc not every region has different format - maybe just different format based on report type (OA vs RT) # Add report formatting based on report type (operational/research) - if(type=="OA" | type=="UP" | type=="MT"){ + if (type == "OA" | type == "UP" | type == "MT") { # Add report formatting based on region - if(office=="AFSC"){ + if (office == "AFSC") { - } else if(office=="NEFSC"){ + } else if (office == "NEFSC") { - } else if(office=="NWFSC"){ + } else if (office == "NWFSC") { template <- paste0( "output: ", " ", "sa" ) - } else if(office=="PIFSC"){ + } else if (office == "PIFSC") { - } else if(office=="SEFSC"){ + } else if (office == "SEFSC") { - } else if(office=="SWFSC"){ + } else if (office == "SWFSC") { } else { print("office (FSC) is not defined. Please define which office you are associated with.") } - } else if (type=="RT" | type=="FULL"){ + } else if (type == "RT" | type == "FULL") { # Add report formatting based on region - if(office=="AFSC"){ + if (office == "AFSC") { - } else if(office=="NEFSC"){ + } else if (office == "NEFSC") { - } else if(office=="NWFSC"){ + } else if (office == "NWFSC") { - } else if(office=="PIFSC"){ + } else if (office == "PIFSC") { - } else if(office=="SEFSC"){ + } else if (office == "SEFSC") { - } else if(office=="SWFSC"){ + } else if (office == "SWFSC") { } else { print("office (FSC) is not defined. Please define which office you are associated with.") diff --git a/R/write_harv_proj_table.R b/R/write_harv_proj_table.R index 42234881..776f538e 100644 --- a/R/write_harv_proj_table.R +++ b/R/write_harv_proj_table.R @@ -13,7 +13,6 @@ #' @export #' #' @examples write_harv_proj_table(tier = 3) - write_harv_proj_table <- function( results_last = 9999, results_lastp1 = 9999, @@ -21,25 +20,23 @@ write_harv_proj_table <- function( results_currp1 = 9999, tier = NULL, overfishing_last = "NO", - overfishing_curr = "NO" - ){ - + overfishing_curr = "NO") { # Pull current projection results # Need to update function to pull these results after converter is finished - # proj_last <- results_last |> - # dplyr::select(M) - # - # proj_lastp1 <- results_lastp1 |> - # dplyr::select(M) - # - # proj_curr <- results_lastp1 |> - # dplyr::select(M) - # - # proj_currp1 <- results_lastp1 |> - # dplyr::select(M) - # - # proj_res <- list(results_last, results_lastp1, results_curr, results_currp1) |> - # purrr::map(dplyr::select(M)) + # proj_last <- results_last |> + # dplyr::select(M) + # + # proj_lastp1 <- results_lastp1 |> + # dplyr::select(M) + # + # proj_curr <- results_lastp1 |> + # dplyr::select(M) + # + # proj_currp1 <- results_lastp1 |> + # dplyr::select(M) + # + # proj_res <- list(results_last, results_lastp1, results_curr, results_currp1) |> + # purrr::map(dplyr::select(M)) # Temporary fill proj_last <- 9999 @@ -49,10 +46,14 @@ write_harv_proj_table <- function( proj_res <- 9999 # Write table contents - quantity <- c("M (natural mortality rate", "Tier", "Biomass (t)", "F OFL", "maxF ABC", "F ABC","OFL (t)", - "maxABC (t)", "ABC (t)") - status <- c("Status", "As determined last year for: current year - 2", "As determined last year for: current year - 1", - "As determined this year for: current year - 1", "As determined this year for: current year") + quantity <- c( + "M (natural mortality rate", "Tier", "Biomass (t)", "F OFL", "maxF ABC", "F ABC", "OFL (t)", + "maxABC (t)", "ABC (t)" + ) + status <- c( + "Status", "As determined last year for: current year - 2", "As determined last year for: current year - 1", + "As determined this year for: current year - 1", "As determined this year for: current year" + ) overfishing <- c("Overfishing", overfishing_last, NA, overfishing_curr, NA) # Build table @@ -75,11 +76,10 @@ write_harv_proj_table <- function( proj_currp1 = "As estimated or recommended this year for:" ) |> flextable::merge_h(part = "header") |> - flextable::vline(j = c(1,3), part = "body") |> + flextable::vline(j = c(1, 3), part = "body") |> flextable::vline(j = c(1), part = "header") |> flextable::hline(part = "header") |> flextable::align(part = "header", align = "center") return(proj_tab) - } diff --git a/R/write_title.R b/R/write_title.R index 125ec709..b694bfbc 100644 --- a/R/write_title.R +++ b/R/write_title.R @@ -22,70 +22,65 @@ write_title <- function( year = NULL, complex = NULL, type = NULL, - spp_latin = NULL -){ - if(is.null(year)){ - year = format(Sys.Date(), "%Y") + spp_latin = NULL) { + if (is.null(year)) { + year <- format(Sys.Date(), "%Y") } # Create title dependent on regional language - if(office=="AFSC"){ - if(is.null(complex)){ - title = paste0("Assessment of the ", species, " Stock in the ", region) + if (office == "AFSC") { + if (is.null(complex)) { + title <- paste0("Assessment of the ", species, " Stock in the ", region) } else { - title = paste0("Assessment of the ", species, " Stock Complex in the ", region) + title <- paste0("Assessment of the ", species, " Stock Complex in the ", region) } - } else if(office=="NEFSC"){ - if(as.numeric(format(Sys.Date(), "%m")) %in% c(3,4,5)){ - season = "Spring" - } else if(as.numeric(format(Sys.Date(), "%m")) %in% c(6,7,8)){ - season = "Summer" - } else if(as.numeric(format(Sys.Date(), "%m")) %in% c(9,10,11)){ - season = "Fall" - } else if(as.numeric(format(Sys.Date(), "%m")) %in% c(12,1,2)){ - season = "Winter" + } else if (office == "NEFSC") { + if (as.numeric(format(Sys.Date(), "%m")) %in% c(3, 4, 5)) { + season <- "Spring" + } else if (as.numeric(format(Sys.Date(), "%m")) %in% c(6, 7, 8)) { + season <- "Summer" + } else if (as.numeric(format(Sys.Date(), "%m")) %in% c(9, 10, 11)) { + season <- "Fall" + } else if (as.numeric(format(Sys.Date(), "%m")) %in% c(12, 1, 2)) { + season <- "Winter" } - if(type=="RT"){ - title = paste0("Research Track Assessment for ", species, " (", spp_latin, ") ", season, " ", year) + if (type == "RT") { + title <- paste0("Research Track Assessment for ", species, " (", spp_latin, ") ", season, " ", year) } else { - title = paste0("Management Track Assessment of ", species, " (", spp_latin, ") ", season, " ", year) + title <- paste0("Management Track Assessment of ", species, " (", spp_latin, ") ", season, " ", year) } - - } else if(office=="NWFSC"){ - if(is.null(region)){ - title = paste0("Status of the ", species, " stock along the U.S. West Coast in ", year) + } else if (office == "NWFSC") { + if (is.null(region)) { + title <- paste0("Status of the ", species, " stock along the U.S. West Coast in ", year) } else { # region in NW should be specified as a state - title = paste0("Status of the ", species, " stock in U.S. waters off the coast of ", region, " in ", year) + title <- paste0("Status of the ", species, " stock in U.S. waters off the coast of ", region, " in ", year) } - - } else if(office=="PIFSC"){ - if(is.null(region)){ - title = paste0("Stock Assessment for ", species, " (", spp_latin, ") along the main Hawaiian Islands in ", year) + } else if (office == "PIFSC") { + if (is.null(region)) { + title <- paste0("Stock Assessment for ", species, " (", spp_latin, ") along the main Hawaiian Islands in ", year) } else { - title = paste0("Stock Assessment for ", species, " (", spp_latin, ") on ", region, " in ", year) + title <- paste0("Stock Assessment for ", species, " (", spp_latin, ") on ", region, " in ", year) } - } else if(office=="SEFSC"){ - title = paste0("SEDAR XX Assessment Report for ", species, " (", spp_latin, ") in the ", region, " in ", year) - - } else if(office=="SWFSC"){ - if(is.null(region)){ - title = paste0("Status of the ", species, " stock along the U.S. West Coast in ", year) + } else if (office == "SEFSC") { + title <- paste0("SEDAR XX Assessment Report for ", species, " (", spp_latin, ") in the ", region, " in ", year) + } else if (office == "SWFSC") { + if (is.null(region)) { + title <- paste0("Status of the ", species, " stock along the U.S. West Coast in ", year) } else { # region in NW should be specified as a state - title = paste0("Status of the ", species, " stock in U.S. waters off the coast of ", region, " in ", year) + title <- paste0("Status of the ", species, " stock in U.S. waters off the coast of ", region, " in ", year) } } else { print("office (FSC) is not defined. Please define which office you are associated with.") } # Cohesive title for any stock assessment - # if(type %in% c('OA', 'UP')){ - # title = paste0("Stock Assessment Update for the ", species, " Stock in the ", region, " ", year) - # } else { - # title = paste0("Stock Assessment Report for the ", species, " Stock in the ", region, " ", year) - # } + # if(type %in% c('OA', 'UP')){ + # title = paste0("Stock Assessment Update for the ", species, " Stock in the ", region, " ", year) + # } else { + # title = paste0("Stock Assessment Report for the ", species, " Stock in the ", region, " ", year) + # } return(title) } - diff --git a/inst/templates/skeleton/01_executive_summary.qmd b/inst/templates/skeleton/01_executive_summary.qmd index 1fb9a5ec..4e6bb764 100644 --- a/inst/templates/skeleton/01_executive_summary.qmd +++ b/inst/templates/skeleton/01_executive_summary.qmd @@ -8,9 +8,9 @@ #| eval: true #| warning: false #| echo: false -if(params$office=="NEFSC"){ +if (params$office == "NEFSC") { a <- knitr::knit_child("01a_proj_table.qmd", quiet = TRUE) - cat(a, sep='\n') + cat(a, sep = "\n") } ``` @@ -21,5 +21,5 @@ if(params$office=="NEFSC"){ #| warning: false #| echo: false a <- knitr::knit_child("01b_refpt_table.qmd", quiet = TRUE) -cat(a, sep='\n') +cat(a, sep = "\n") ``` diff --git a/inst/templates/skeleton/01a_proj_table.qmd b/inst/templates/skeleton/01a_proj_table.qmd index 85e5928a..6d50b3cc 100644 --- a/inst/templates/skeleton/01a_proj_table.qmd +++ b/inst/templates/skeleton/01a_proj_table.qmd @@ -3,8 +3,8 @@ ```{r} #| echo: false #| warning: false -a <- seq(1,10,1) -b <- seq(2,20,2) -data.frame(a,b) |> +a <- seq(1, 10, 1) +b <- seq(2, 20, 2) +data.frame(a, b) |> flextable::flextable() ``` diff --git a/man/add_section.Rd b/man/add_section.Rd index 472922bd..c7d26fbb 100644 --- a/man/add_section.Rd +++ b/man/add_section.Rd @@ -31,3 +31,6 @@ as a child document. \description{ Add New Section to Template } +\examples{ +add_section(title = "Ecosystem Considerations", location = "after-discussion") +} diff --git a/man/convert_output.Rd b/man/convert_output.Rd index 73c29751..900bb55a 100644 --- a/man/convert_output.Rd +++ b/man/convert_output.Rd @@ -23,7 +23,7 @@ adapt results among regional assessments. Format stock assessment output files. Function is unfinished } \examples{ -convert_output(output.file = "CumReport.sso", outdir = "~", model = 'ss', file.format = 'multi', multi.file = FALSE) +convert_output(output.file = "CumReport.sso", outdir = "~", model = "ss", file.format = "multi", multi.file = FALSE) } \author{ diff --git a/man/create_template.Rd b/man/create_template.Rd index de34b420..9d1d379b 100644 --- a/man/create_template.Rd +++ b/man/create_template.Rd @@ -108,10 +108,12 @@ each of the child documents should be edited separately. Create Stock Assessment Report Template } \examples{ -create_template(new_template = TRUE, format = "pdf", -office = "NEFSC", region = "GB", species = "Bluefish",spp_latin = "bluishfihesi", -year = 2024, author = c("John Snow", "Danny Phantom", "Patrick Star"), -include_affiliation = TRUE, parameters = TRUE, param_names = c("fleet1", "fleet2", "model"), -param_values = c("Commercial", "Recreational", "Woods Hole Assessment Model"), -type = "RT") +create_template( + new_template = TRUE, format = "pdf", + office = "NEFSC", region = "GB", species = "Bluefish", spp_latin = "bluishfihesi", + year = 2024, author = c("John Snow", "Danny Phantom", "Patrick Star"), + include_affiliation = TRUE, parameters = TRUE, param_names = c("fleet1", "fleet2", "model"), + param_values = c("Commercial", "Recreational", "Woods Hole Assessment Model"), + type = "RT" +) } diff --git a/man/export_object.Rd b/man/export_object.Rd index 56ef6d26..1c8fd301 100644 --- a/man/export_object.Rd +++ b/man/export_object.Rd @@ -21,9 +21,9 @@ Function to export specified object from R environment found in the stock assessment report. } \examples{ -source <- c("NMFS Groundfish Survey","","U.S. Trawl Fisheries", "", "") -data <- c("Survey biomass","Age Composition","Catch","Age Composition","Length Composition") -years <- c("1984-1999 (triennial), 2001-2013 (biennial)","1984, 1987, 1990, 1993, 1996, 1999, 2003, 2005, 2007, 2009, 2011","1961-2013", "1990,1998-2002, 2004, 2005, 2006, 2008, 2010","1963-1977, 1991-1997") +source <- c("NMFS Groundfish Survey", "", "U.S. Trawl Fisheries", "", "") +data <- c("Survey biomass", "Age Composition", "Catch", "Age Composition", "Length Composition") +years <- c("1984-1999 (triennial), 2001-2013 (biennial)", "1984, 1987, 1990, 1993, 1996, 1999, 2003, 2005, 2007, 2009, 2011", "1961-2013", "1990,1998-2002, 2004, 2005, 2006, 2008, 2010", "1963-1977, 1991-1997") test_obj <- data.frame(source, data, years) export_object(object = test_obj, file_format = "csv") diff --git a/man/generate_citation.Rd b/man/generate_citation.Rd index bbfb7572..fdaf6f8f 100644 --- a/man/generate_citation.Rd +++ b/man/generate_citation.Rd @@ -23,8 +23,10 @@ the stock assessment report generated in the ASAR package. Generate Citation for Stock Assessment Report } \examples{ -generate_citation(title = "SA Report for Jellyfish", -author = c("John Snow", "Danny Phantom", "Patrick Star"), -year = 2024, office = "NEFSC") +generate_citation( + title = "SA Report for Jellyfish", + author = c("John Snow", "Danny Phantom", "Patrick Star"), + year = 2024, office = "NEFSC" +) }