diff --git a/.Rbuildignore b/.Rbuildignore index 8a70a912..12d40976 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,4 +9,8 @@ ^\.positai$ ^\.claude$ ^\.octocov\.yml$ -^\.devcontainer$ \ No newline at end of file +^\.devcontainer$ +^CITATION\.cff$ +^CODE_OF_CONDUCT\.md$ +^CONTRIBUTING\.md$ +^(R|data|inst|tests|vignettes)/README\.md$ diff --git a/.github/workflows/update-ss3-example-data.yml b/.github/workflows/update-ss3-example-data.yml index 789c187f..289ea269 100644 --- a/.github/workflows/update-ss3-example-data.yml +++ b/.github/workflows/update-ss3-example-data.yml @@ -27,7 +27,9 @@ jobs: extra-packages: any::pak, any::usethis, local::. - name: Update example data - run: Rscript data-raw/DATASET_SS3.R + run: Rscript data-raw/DATASET_SS3-r4ss.R + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - name: Commit and push updated example data if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository diff --git a/NAMESPACE b/NAMESPACE index 452b61d8..69317fa0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -39,3 +39,4 @@ export(table_total_catch) export(theme_noaa) export(theme_table) importFrom(lifecycle,deprecated) +importFrom(rlang,.data) diff --git a/R/conout_bam.R b/R/conout_bam.R index 414beb88..83215146 100644 --- a/R/conout_bam.R +++ b/R/conout_bam.R @@ -3,6 +3,8 @@ #' Does not change naming conventions. #' #' @inheritParams convert_output +#' @param out_new The empty standard output data frame from +#' [convert_output()], which sets the columns of the output. #' #' @returns Reshaped data frame. conout_bam <- function( diff --git a/R/conout_rceattle.R b/R/conout_rceattle.R index 515824c2..117fdae4 100644 --- a/R/conout_rceattle.R +++ b/R/conout_rceattle.R @@ -3,6 +3,8 @@ #' Does not change naming conventions. #' #' @inheritParams convert_output +#' @param out_new The empty standard output data frame from +#' [convert_output()], which sets the columns of the output. #' #' @returns Reshaped data frame. conout_rceattle <- function( diff --git a/R/conout_ss3.R b/R/conout_ss3.R index 0eb02cc6..6ca8ec69 100644 --- a/R/conout_ss3.R +++ b/R/conout_ss3.R @@ -4,6 +4,8 @@ #' file or returned object from `r4ss::ss_output()`. #' #' @inheritParams convert_output +#' @param out_new The empty standard output data frame from +#' [convert_output()], which sets the columns of the output. #' #' @returns Reshaped data frame. conout_ss3 <- function( diff --git a/R/data.R b/R/data.R index 116a3b5a..86a5a9f0 100644 --- a/R/data.R +++ b/R/data.R @@ -44,10 +44,8 @@ #' 2018 Gulf of Alaska Pollock stock assessment output #' -#' Standardized output of the 2018 Gulf of Alaska Pollock stock assessment -#' produced from Rceattle including all of the values needed to create -#' plots and tables in {stockplotr}. The example can be found and run from the -#' Rceattle repository. +#' Output of the 2018 Gulf of Alaska Pollock stock assessment produced from Rceattle, standardized +#' using stockplotr::convert_output(). The example can be found and run from the Rceattle repository. #' #' @docType data #' @@ -93,7 +91,7 @@ #' @keywords datasets #' #' @references Adams, G. D., Holsman, K. K., Barbeaux, S. J., Dorn, M. W., Ianelli, J. N., Spies, I., … Punt, A. E. (2022) -#' (\href{https://doi.org/10.1016/j.fishres.2022.106303}) +#' (\doi{10.1016/j.fishres.2022.106303}) #' #' @source \href{https://github.com/afsc-assessments/Rceattle/blob/main/examples/Fit_2018_GOA_single-species_models.R}{Rceattle Example} #' @@ -152,7 +150,7 @@ #' @keywords datasets #' #' @references SEDAR (2018) -#' (\href{https://sedarweb.org/documents/sedar-55-stock-assessment-report-south-atlantic-vermilion-snapper/}) +#' (\url{https://sedarweb.org/documents/sedar-55-stock-assessment-report-south-atlantic-vermilion-snapper/}) #' #' @examples #' data(vermilion_snapper) @@ -215,4 +213,4 @@ #' data(ss3_simple) #' head(ss3_simple) #' unique(ss3_simple$label) -"ss3_simple" \ No newline at end of file +"ss3_simple" diff --git a/R/extract_sis_data.R b/R/extract_sis_data.R index 54cfdc90..0e3e3999 100644 --- a/R/extract_sis_data.R +++ b/R/extract_sis_data.R @@ -383,15 +383,15 @@ extract_sis_data <- function(sis_data_dir = getwd(), cli::cli_alert_info("Existing sis_assmt_template.csv or sis_ts_template.csv found in {sis_data_dir}.") overwrite <- readline("Do you want to overwrite the existing files? (y/n): ") if (tolower(overwrite) == "y") { - write.csv(assmt_dat, assmt_dat_path, row.names = FALSE) - write.csv(ts_dat_filled, ts_dat_path, row.names = FALSE) + utils::write.csv(assmt_dat, assmt_dat_path, row.names = FALSE) + utils::write.csv(ts_dat_filled, ts_dat_path, row.names = FALSE) cli::cli_alert_success("Files overwritten successfully.") } else { cli::cli_alert_info("Files not overwritten. Please rename the files, then rerun this function to save the data extracted in this function.") } } else { - write.csv(assmt_dat, assmt_dat_path, row.names = FALSE) - write.csv(ts_dat_filled, ts_dat_path, row.names = FALSE) + utils::write.csv(assmt_dat, assmt_dat_path, row.names = FALSE) + utils::write.csv(ts_dat_filled, ts_dat_path, row.names = FALSE) cli::cli_alert_success("Files saved successfully in {sis_data_dir}.") } diff --git a/R/plot_spawning_biomass.R b/R/plot_spawning_biomass.R index 12964619..deed9e0f 100644 --- a/R/plot_spawning_biomass.R +++ b/R/plot_spawning_biomass.R @@ -130,7 +130,7 @@ plot_spawning_biomass <- function( ref_line = "msy", unit_label = NULL, era = NULL, - lbs = lifecycle::deprecate(), + lbs = lifecycle::deprecated(), module = NULL, scale_amount = 1, relative = FALSE, diff --git a/R/save_all_plots.R b/R/save_all_plots.R index db745c57..41e33a87 100644 --- a/R/save_all_plots.R +++ b/R/save_all_plots.R @@ -6,6 +6,10 @@ #' plotting functions for greater customization of figures and tables. #' #' @inheritParams plot_spawning_biomass +#' @param figures_tables_dir Path. Directory where the rda files are saved, +#' in "figures" and "tables" folders that are created if needed. +#' +#' Default: the working directory (`getwd()`) #' #' @param plot_recruitment_options List. List object of parameter values to pass #' directly to the `plot_recruitment` function. All default parameters for the diff --git a/R/stockplotr-package.R b/R/stockplotr-package.R index 7c254395..4f6faee8 100644 --- a/R/stockplotr-package.R +++ b/R/stockplotr-package.R @@ -3,6 +3,7 @@ ## usethis namespace: start #' @importFrom lifecycle deprecated +#' @importFrom rlang .data ## usethis namespace: end NULL diff --git a/R/table_biomass_abundance_catch.R b/R/table_biomass_abundance_catch.R index b168605c..1b7a9f8c 100644 --- a/R/table_biomass_abundance_catch.R +++ b/R/table_biomass_abundance_catch.R @@ -115,7 +115,7 @@ table_biomass_abundance_catch <- function( estimate_lower = mean(as.numeric(estimate_lower), na.rm = TRUE), uncertainty_label = unique(uncertainty_label), uncertainty = mean(uncertainty, na.rm = TRUE), - unit = unique(unit), + unit = unique(.data$unit), .by = c(year, model, label) ) # |> # dplyr::ungroup() @@ -129,7 +129,7 @@ table_biomass_abundance_catch <- function( estimate_lower = mean(as.numeric(estimate_lower), na.rm = TRUE), uncertainty_label = unique(uncertainty_label), uncertainty = mean(uncertainty, na.rm = TRUE), - unit = unique(unit), + unit = unique(.data$unit), .by = c(year, model, label) ) # |> # dplyr::ungroup() @@ -163,8 +163,8 @@ table_biomass_abundance_catch <- function( if (is.null(get(paste0(unit_name, "_label")))) { unit_label <- filtered_data |> dplyr::filter(grepl(x, unit_name), - !is.na(unit)) |> - dplyr::pull(unit) |> + !is.na(.data$unit)) |> + dplyr::pull("unit") |> unique() if (is.na(unit_label) || length(unit_label) == 0) { cli::cli_alert_warning("No unit label found in the data for {unit_name}. Please provide a unit label using the '{unit_name}_label' argument.") diff --git a/R/utils_rda.R b/R/utils_rda.R index 48242a57..8ece629c 100644 --- a/R/utils_rda.R +++ b/R/utils_rda.R @@ -549,10 +549,6 @@ insert_kqs <- function(..., dir=getwd()) { #' #' Default: the working directory (`getwd()`) #' -#' @param year Number. Assessment year -#' -#' Default: the current year -#' #' @param ref_line String. Reference line value #' #' Default: "msy" diff --git a/man/conout_bam.Rd b/man/conout_bam.Rd index 7b3ee972..e8d1417a 100644 --- a/man/conout_bam.Rd +++ b/man/conout_bam.Rd @@ -10,6 +10,9 @@ conout_bam(file, out_new, fleet_names = NULL) \item{file}{Path. Assessment model output file path. Currently accepts SS3 \code{r4ss::ss_output()} or Report.sso file (being deprecated), BAM .rda file, Rceattle model object, and FIMS model object.} +\item{out_new}{The empty standard output data frame from +\code{\link[=convert_output]{convert_output()}}, which sets the columns of the output.} + \item{fleet_names}{Character vector. Names of fleets in the assessment model as shortened in the output file or names of fleets to replace the native fleet names in the output. For example, if fleet names in the model are 1, 2, 3 diff --git a/man/conout_rceattle.Rd b/man/conout_rceattle.Rd index 85612b51..0e765689 100644 --- a/man/conout_rceattle.Rd +++ b/man/conout_rceattle.Rd @@ -10,6 +10,9 @@ conout_rceattle(file, out_new, fleet_names = NULL) \item{file}{Path. Assessment model output file path. Currently accepts SS3 \code{r4ss::ss_output()} or Report.sso file (being deprecated), BAM .rda file, Rceattle model object, and FIMS model object.} +\item{out_new}{The empty standard output data frame from +\code{\link[=convert_output]{convert_output()}}, which sets the columns of the output.} + \item{fleet_names}{Character vector. Names of fleets in the assessment model as shortened in the output file or names of fleets to replace the native fleet names in the output. For example, if fleet names in the model are 1, 2, 3 diff --git a/man/conout_ss3.Rd b/man/conout_ss3.Rd index fe5de1e8..aa808877 100644 --- a/man/conout_ss3.Rd +++ b/man/conout_ss3.Rd @@ -10,6 +10,9 @@ conout_ss3(file, out_new, fleet_names = NULL) \item{file}{Path. Assessment model output file path. Currently accepts SS3 \code{r4ss::ss_output()} or Report.sso file (being deprecated), BAM .rda file, Rceattle model object, and FIMS model object.} +\item{out_new}{The empty standard output data frame from +\code{\link[=convert_output]{convert_output()}}, which sets the columns of the output.} + \item{fleet_names}{Character vector. Names of fleets in the assessment model as shortened in the output file or names of fleets to replace the native fleet names in the output. For example, if fleet names in the model are 1, 2, 3 diff --git a/man/create_rda.Rd b/man/create_rda.Rd index 53563681..78917fca 100644 --- a/man/create_rda.Rd +++ b/man/create_rda.Rd @@ -45,10 +45,6 @@ Default: 1} \item{table_df}{Data frame. The data frame that the table will be made into for purposes of exporting a latex formatted table.} - -\item{year}{Number. Assessment year - -Default: the current year} } \value{ An rda package for a plot or table object. Requires an diff --git a/man/plot_spawning_biomass.Rd b/man/plot_spawning_biomass.Rd index eb3f3302..ab616183 100644 --- a/man/plot_spawning_biomass.Rd +++ b/man/plot_spawning_biomass.Rd @@ -12,7 +12,7 @@ plot_spawning_biomass( ref_line = "msy", unit_label = NULL, era = NULL, - lbs = lifecycle::deprecate(), + lbs = lifecycle::deprecated(), module = NULL, scale_amount = 1, relative = FALSE, diff --git a/man/pollock.Rd b/man/pollock.Rd index 8b31cd17..4a138953 100644 --- a/man/pollock.Rd +++ b/man/pollock.Rd @@ -61,6 +61,6 @@ unique(pollock$label) } \references{ Adams, G. D., Holsman, K. K., Barbeaux, S. J., Dorn, M. W., Ianelli, J. N., Spies, I., … Punt, A. E. (2022) -(\href{https://doi.org/10.1016/j.fishres.2022.106303}) +(\doi{10.1016/j.fishres.2022.106303}) } \keyword{datasets} diff --git a/man/save_all_plots.Rd b/man/save_all_plots.Rd index c11d67af..efcd2341 100644 --- a/man/save_all_plots.Rd +++ b/man/save_all_plots.Rd @@ -25,6 +25,11 @@ in \code{ref_line} is used to plot a reference line or calculate relative spawni Default: \code{FALSE}} +\item{figures_tables_dir}{Path. Directory where the rda files are saved, +in "figures" and "tables" folders that are created if needed. + +Default: the working directory (\code{getwd()})} + \item{plot_recruitment_options}{List. List object of parameter values to pass directly to the \code{plot_recruitment} function. All default parameters for the \code{plot_recruitment} function, except for \code{dat}, can be overridden with this list diff --git a/man/vermilion_snapper.Rd b/man/vermilion_snapper.Rd index 27f56b14..69fe7c7a 100644 --- a/man/vermilion_snapper.Rd +++ b/man/vermilion_snapper.Rd @@ -56,6 +56,6 @@ unique(vermilion_snapper$label) } \references{ SEDAR (2018) -(\href{https://sedarweb.org/documents/sedar-55-stock-assessment-report-south-atlantic-vermilion-snapper/}) +(\url{https://sedarweb.org/documents/sedar-55-stock-assessment-report-south-atlantic-vermilion-snapper/}) } \keyword{datasets}