diff --git a/R/conout_bam.R b/R/conout_bam.R index 4f55aa7a..5c8dd8f1 100644 --- a/R/conout_bam.R +++ b/R/conout_bam.R @@ -3,10 +3,11 @@ #' Does not change naming conventions. #' #' @inheritParams convert_output -#' -#' @param file. Assessment model output file path. Currently accepts SS3 -#' Report.sso file, BAM .rda file, Rceattle model object, and FIMS model object. -#' +#' +#' @param file Assessment model output file path or object in the user's +#' environment. Currently accepts SS3 Report.sso file, BAM .rda file, +#' Rceattle model object, and FIMS model object. +#' #' @param out_new The empty standard output data frame from #' [convert_output()], which sets the columns of the output. #' diff --git a/R/conout_rceattle.R b/R/conout_rceattle.R index 4baacd94..6de96017 100644 --- a/R/conout_rceattle.R +++ b/R/conout_rceattle.R @@ -3,10 +3,11 @@ #' Does not change naming conventions. #' #' @inheritParams convert_output -#' -#' @param file. Assessment model output file path. Currently accepts SS3 -#' Report.sso file, BAM .rda file, Rceattle model object, and FIMS model object. -#' +#' +#' @param file Assessment model output file path or object in the user's +#' environment. Currently accepts SS3 Report.sso file, BAM .rda file, +#' Rceattle model object, and FIMS model object. +#' #' @param out_new The empty standard output data frame from #' [convert_output()], which sets the columns of the output. #' diff --git a/R/conout_ss3.R b/R/conout_ss3.R index 79afe4fe..e7278220 100644 --- a/R/conout_ss3.R +++ b/R/conout_ss3.R @@ -4,10 +4,11 @@ #' file or returned object from `r4ss::ss_output()`. #' #' @inheritParams convert_output -#' -#' @param file. Assessment model output file path. Currently accepts SS3 -#' Report.sso file, BAM .rda file, Rceattle model object, and FIMS model object. -#' +#' +#' @param file Assessment model output file path or object in the user's +#' environment. Currently accepts SS3 Report.sso file, BAM .rda file, +#' Rceattle model object, and FIMS model object. +#' #' @param out_new The empty standard output data frame from #' [convert_output()], which sets the columns of the output. #' diff --git a/R/convert_output.R b/R/convert_output.R index 3622f13d..0742ca5c 100644 --- a/R/convert_output.R +++ b/R/convert_output.R @@ -61,15 +61,21 @@ #' @examples #' \dontrun{ #' convert_output( -#' file = here::here("model1", "Report.sso"), -#' model = "ss3", +#' files = here::here("model1", "Report.sso"), +#' models = "ss3", #' fleet_names = c("TWL", "NONTWL"), #' save_dir = here::here("standard_output.rda") #' ) #' convert_output( -#' file = list("model1"=here::here("model1", "Report.sso"), "model2"=here::here("model2", "Report.sso")), -#' model = c("ss3", "ss3"), -#' fleet_names = list("model1"=c("TWL", "NONTWL"), "model2"=c("Fishery1", "Survey1", "Survey2")), +#' files = list( +#' "model1" = here::here("model1", "Report.sso"), +#' "model2" = here::here("model2", "Report.sso") +#' ), +#' models = c("ss3", "ss3"), +#' fleet_names = list( +#' "model1" = c("TWL", "NONTWL"), +#' "model2" = c("Fishery1", "Survey1", "Survey2") +#' ), #' save_dir = here::here("standard_output.rda") #' ) #' } @@ -335,7 +341,7 @@ convert_output <- function( model=model_name, year=as.character(year), month=as.character(month), - block=as.character(block), + block=as.character(.data$block), fleet=as.character(fleet) ) return(tibble::tibble(out_new)) diff --git a/R/extract_sis_data.R b/R/extract_sis_data.R index 1b1cf93f..31e33e08 100644 --- a/R/extract_sis_data.R +++ b/R/extract_sis_data.R @@ -154,7 +154,7 @@ extract_sis_data <- function(sis_data_dir = getwd(), rec <- rda[["figure"]][["layers"]][["geom_line"]][["data"]] recruitment <- rec |> dplyr::group_by(year) |> - dplyr::summarise(sum = sum(predicted_recruitment)) |> + dplyr::summarise(sum = sum(.data$predicted_recruitment)) |> dplyr::rename(Recruitment = sum) }, error = function(e) { diff --git a/R/plot_data_availability.R b/R/plot_data_availability.R index 371908dc..75aa99b2 100644 --- a/R/plot_data_availability.R +++ b/R/plot_data_availability.R @@ -118,7 +118,7 @@ plot_data_availability <- function( # fleet, and year, with `type` a factor in the order the types are plotted data_availability <- function(dat) { if (inherits(dat, "FIMSFrame")) { - dat <- methods::slot(dat, "data") + dat <- dat@data } fims_input <- is.data.frame(dat) && !"label" %in% names(dat) && all(c("type", "fleet", "timing", "observed") %in% names(dat)) diff --git a/R/plot_landings.R b/R/plot_landings.R index 798b52f3..6fe45e37 100644 --- a/R/plot_landings.R +++ b/R/plot_landings.R @@ -207,7 +207,7 @@ plot_landings <- function( labels <- unique(landings_data$label) unit_label <- prepared_data |> dplyr::filter(label %in% labels) |> - dplyr::pull(unit) |> + dplyr::pull("unit") |> unique() unit_label <- unit_label[!is.na(unit_label)][1] if (is.na(unit_label)) { diff --git a/R/table_landings.R b/R/table_landings.R index 98ecf2fc..76e2f568 100644 --- a/R/table_landings.R +++ b/R/table_landings.R @@ -133,9 +133,9 @@ table_landings <- function( cleaned_colnames <- gsub(fleet_pattern, "", colnames(table_data[[1]])) unit_label <- prepared_data |> dplyr::filter(label %in% cleaned_colnames) |> - dplyr::select(unit) |> + dplyr::select("unit") |> unique() |> - dplyr::pull(unit) + dplyr::pull("unit") if (is.na(unit_label)) { cli::cli_alert_warning("No unit label found in the data. Please provide a unit label using the 'unit_label' argument.") unit_label <- "" diff --git a/R/table_projections.R b/R/table_projections.R index b18c429a..27a5bc01 100644 --- a/R/table_projections.R +++ b/R/table_projections.R @@ -107,9 +107,9 @@ table_projections <- function( unit_label <- filtered_data |> dplyr::filter( grepl(x, unit_name), - !is.na(unit) + !is.na(.data$unit) ) |> - dplyr::pull(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/man/conout_bam.Rd b/man/conout_bam.Rd index 3cdb9be6..63a84326 100644 --- a/man/conout_bam.Rd +++ b/man/conout_bam.Rd @@ -7,6 +7,10 @@ conout_bam(file, out_new, fleet_names = NULL) } \arguments{ +\item{file}{Assessment model output file path or object in the user's +environment. Currently accepts SS3 Report.sso file, 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.} @@ -18,9 +22,6 @@ then fleet_names = c("fleet1" = 1, "fleet2" = 2, "fleet3" = 3). Default: NULL Should match length of \code{files} if >1 model.} - -\item{file.}{Assessment model output file path. Currently accepts SS3 -Report.sso file, BAM .rda file, Rceattle model object, and FIMS model object.} } \value{ Reshaped data frame. diff --git a/man/conout_rceattle.Rd b/man/conout_rceattle.Rd index 7702fba6..62fd7e18 100644 --- a/man/conout_rceattle.Rd +++ b/man/conout_rceattle.Rd @@ -7,6 +7,10 @@ conout_rceattle(file, out_new, fleet_names = NULL) } \arguments{ +\item{file}{Assessment model output file path or object in the user's +environment. Currently accepts SS3 Report.sso file, 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.} @@ -18,9 +22,6 @@ then fleet_names = c("fleet1" = 1, "fleet2" = 2, "fleet3" = 3). Default: NULL Should match length of \code{files} if >1 model.} - -\item{file.}{Assessment model output file path. Currently accepts SS3 -Report.sso file, BAM .rda file, Rceattle model object, and FIMS model object.} } \value{ Reshaped data frame. diff --git a/man/conout_ss3.Rd b/man/conout_ss3.Rd index 25a79239..35475c87 100644 --- a/man/conout_ss3.Rd +++ b/man/conout_ss3.Rd @@ -7,6 +7,10 @@ conout_ss3(file, out_new, fleet_names = NULL) } \arguments{ +\item{file}{Assessment model output file path or object in the user's +environment. Currently accepts SS3 Report.sso file, 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.} @@ -18,9 +22,6 @@ then fleet_names = c("fleet1" = 1, "fleet2" = 2, "fleet3" = 3). Default: NULL Should match length of \code{files} if >1 model.} - -\item{file.}{Assessment model output file path. Currently accepts SS3 -Report.sso file, BAM .rda file, Rceattle model object, and FIMS model object.} } \value{ Reshaped data frame. diff --git a/man/convert_output.Rd b/man/convert_output.Rd index 71f61f17..6ba3e0f7 100644 --- a/man/convert_output.Rd +++ b/man/convert_output.Rd @@ -74,15 +74,21 @@ Other estimates are relabeled with \code{fims_var_names.csv} (e.g., \examples{ \dontrun{ convert_output( - file = here::here("model1", "Report.sso"), - model = "ss3", + files = here::here("model1", "Report.sso"), + models = "ss3", fleet_names = c("TWL", "NONTWL"), save_dir = here::here("standard_output.rda") ) convert_output( - file = list("model1"=here::here("model1", "Report.sso"), "model2"=here::here("model2", "Report.sso")), - model = c("ss3", "ss3"), - fleet_names = list("model1"=c("TWL", "NONTWL"), "model2"=c("Fishery1", "Survey1", "Survey2")), + files = list( + "model1" = here::here("model1", "Report.sso"), + "model2" = here::here("model2", "Report.sso") + ), + models = c("ss3", "ss3"), + fleet_names = list( + "model1" = c("TWL", "NONTWL"), + "model2" = c("Fishery1", "Survey1", "Survey2") + ), save_dir = here::here("standard_output.rda") ) }