Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ Suggests:
r4ss,
rmarkdown,
testthat (>= 3.0.0)
Remotes:
r4ss/r4ss
VignetteBuilder:
knitr
Remotes:
r4ss/r4ss
Config/roxygen2/version: 8.1.1
Config/testthat/edition: 3
Config/testthat/parallel: true
Expand Down
24 changes: 12 additions & 12 deletions R/add_caption_alt_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
#' caption, and alt_text for a figure or table not present in stockplotr.
#'
#' @inheritParams create_rda
#'
#' @param topic_label String. Figure/table label. For automated matching in
#'
#' @param topic_label String. Figure/table label. For automated matching in
#' asar-based report, it must match the label in your plot's chunk options, MINUS
#' the "fig-" or "tab-". For example, the label "custom_table1" would match up
#' the "fig-" or "tab-". For example, the label "custom_table1" would match up
#' properly with the "tbl-custom_table1" code chunk label.
#'
#'
#' @param caption String. Figure/table caption.
#'
#'
#' @param alt_text String. Figure alternative text. Unnecessary for text-based tables.
#'
#'
#' Default: ""
#'
#'
#' @param dir Path. Path to the existing captions_alt_text.csv file that will be
#' updated with the new caption and alt text.
#'
#' Default: file.path(getwd(), "captions_alt_text.csv")
#'
#' @export
#'
#'
#' @examples \dontrun{
#' add_caption_alt_text(
#' topic_label = "my_topic",
Expand All @@ -38,22 +38,22 @@ add_caption_alt_text <- function(topic_label,
alt_text = "",
dir = file.path(getwd(), "captions_alt_text.csv")) {
captions_alt_text <- utils::read.csv(dir)

if (fig_or_table == tolower("figure") & alt_text == "") {
cli::cli_alert_warning("No alt text provided for figure {topic_label}.")
cli::cli_alert_warning("Figure alt text is necessary to pass asar report accessibility checks.")
cli::cli_alert_info("Learn how to write descriptive alt text with the asar 'Increasing Report Accessibility' vignette: {.url https://nmfs-ost.github.io/asar/articles/accessibility_guide.html#alternative-text}.")
}

new_row <- data.frame(
label = topic_label,
type = fig_or_table,
caption = caption,
alt_text = alt_text
)

captions_alt_text <- rbind(captions_alt_text, new_row)

utils::write.csv(
captions_alt_text,
file = dir,
Expand Down
40 changes: 20 additions & 20 deletions R/conout_bam.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' Code to convert BAM output to standard framework.
#'
#'
#' Does not change naming conventions.
#'
#' @inheritParams convert_output
Expand All @@ -8,13 +8,13 @@
#'
#' @returns Reshaped data frame.
conout_bam <- function(
file,
out_new,
fleet_names = NULL
file,
out_new,
fleet_names = NULL
) {
# Extract values from BAM output - model file after following ADMB2R
dat <- dget(file)

# Find fleet names
if (is.null(fleet_names)) {
# Extract names from indices
Expand All @@ -24,13 +24,13 @@ conout_bam <- function(
# Extract names from landings
landings <- dat$t.series |>
dplyr::select(dplyr::contains("L.") & dplyr::contains(".ob") |
dplyr::contains("D.") & dplyr::contains(".ob"))
dplyr::contains("D.") & dplyr::contains(".ob"))
fleets_land <- stringr::str_extract(as.vector(colnames(landings)), "(?<=L\\.)\\w+(?=\\.ob)")
fleets_disc <- stringr::str_extract(as.vector(colnames(landings)), "(?<=D\\.)\\w+(?=\\.ob)")
# Extract names from lof F dev
parm <- dat$parm.tvec |>
dplyr::select(dplyr::contains("log.F.dev.") |
dplyr::contains("log.F.dev.") & dplyr::contains(".D"))
dplyr::contains("log.F.dev.") & dplyr::contains(".D"))
# fleets_parm_D <- stringr::str_extract(as.vector(colnames(parm)), "(?<=log\\.F\\.dev\\.)\\w+(?=\\.D)")
fleets_parm <- stringr::str_extract(as.vector(colnames(parm)), "(?<=log\\.F\\.dev\\.)\\w+")
fleets <- unique(tolower(c(fleets_ind, fleets_land, fleets_disc, fleets_parm)))
Expand All @@ -48,13 +48,13 @@ conout_bam <- function(
cli::cli_alert_info("{fleet_names}")
# Create list for morphed dfs to go into (for rbind later)
out_list <- list()

factors <- c("year", "fleet", "fleet_name", "age", "sex", "area", "seas", "season", "time", "era", "subseas", "subseason", "platoon", "platoo", "growth_pattern", "gp", "nsim", "age_a")
errors <- c("StdDev", "sd", "se", "SE", "cv", "CV", "stddev")
units <- c("mt", "lbs", "eggs")
# argument for function when model == BAM
# fleet_names <- c("cl", "cL","cp","mrip","ct", "hb", "HB", "comm","Mbft","CVID")

##### BAM loop ----
# Extract data from list fit to output df
# Loop over all items to output each object/transform
Expand Down Expand Up @@ -97,7 +97,7 @@ conout_bam <- function(
df <- df |>
dplyr::rename_with(
~ ifelse(max(as.numeric(df$year)) < 50,
c("age_a"), c("year")
c("age_a"), c("year")
),
year
)
Expand Down Expand Up @@ -127,7 +127,7 @@ conout_bam <- function(
TRUE ~ names(extract[[1]][i])
)
# label_init = names(extract[[1]][i]),

# label = dplyr::case_when(
# is.na(fleet) ~ names(extract[[1]][i]),
# TRUE ~ stringr::str_replace(tolower(label), paste(".", fleet_names, sep = "", collapse = "|"), "")
Expand Down Expand Up @@ -505,7 +505,7 @@ conout_bam <- function(
cli::cli_alert_warning(paste(names(extract), " not compatible.", sep = ""))
} # close if statement
} # close loop over objects listed in dat file

# Place out_list into a single data frame
# VIRG, INIT, TIME, FORE
out_new <- Reduce(rbind, out_list) |>
Expand All @@ -515,15 +515,15 @@ conout_bam <- function(
label = tolower(label)
)
# if (model == "bam") {
out_new <- dplyr::mutate(
out_new,
era = dplyr::case_when(
year < dat$parms$styr ~ "init",
year >= dat$parms$styr & year <= dat$parms$endyr ~ "time",
year > dat$parms$endyr ~ "fore",
TRUE ~ NA
)
out_new <- dplyr::mutate(
out_new,
era = dplyr::case_when(
year < dat$parms$styr ~ "init",
year >= dat$parms$styr & year <= dat$parms$endyr ~ "time",
year > dat$parms$endyr ~ "fore",
TRUE ~ NA
)
)
# }
return(out_new)
}
Loading
Loading