Skip to content

Commit

Permalink
Extracted 2 more key quantities (min, max M rate)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbreitbart-NOAA committed Jan 27, 2025
1 parent 32c75e7 commit 2d42cf1
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions R/write_captions.R
Original file line number Diff line number Diff line change
Expand Up @@ -284,28 +284,48 @@ write_captions <- function(dat, # converted model output object
round(digits = 2)

## natural mortality (M)- bam examples have label as natural_mortality
## but other formats don't (in input) (use if statement)
## but other formats don't (in input)
# minimum age of M
# M.age.min <- dat |>
# dplyr::select(age) |>
# dplyr::filter(!is.na(age)) |>
# dplyr::slice(which.min(age)) |>
# as.numeric()
#
# # maximum age of M
# M.age.max <- dat |>
# dplyr::select(age) |>
# dplyr::filter(!is.na(age)) |>
# dplyr::slice(which.max(age)) |>
# as.numeric()

# minimum M rate
if ("natural_mortality" %in% dat$label){
M.age.min <- dat |>
dplyr::filter(label == "natural_mortality") |>
dplyr::select(age) |>
dplyr::filter(!is.na(age)) |>
dplyr::slice(which.min(age)) |>
as.numeric()
} else {
M.age.min <- dat |>
# dplyr::filter(label == "natural_mortality") |>
dplyr::select(age) |>
dplyr::filter(!is.na(age)) |>
dplyr::slice(which.min(age)) |>
as.numeric()
}

# maximum age of M
if ("natural_mortality" %in% dat$label){
M.age.max <- dat |>
dplyr::filter(label == "natural_mortality") |>
dplyr::select(age) |>
dplyr::filter(!is.na(age)) |>
dplyr::slice(which.max(age)) |>
as.numeric()
} else {
M.age.max <- dat |>
# dplyr::filter(label == "natural_mortality") |>
dplyr::select(age) |>
dplyr::filter(!is.na(age)) |>
dplyr::slice(which.max(age)) |>
as.numeric()
}

# minimum M rate- don't code quantities yet (see how it's coded in future fig)
# M.rate.min <- dat |>
# dplyr::filter(
# grepl("natural_mortality", label)) |>
# -label = natural_mortality (min); est in est col

# maximum M rate
# maximum M rate- don't code quantities yet (see how it's coded in future fig)
# M.rate.max <-
# -label = natural_mortality (min); est in est col

Expand Down Expand Up @@ -837,8 +857,8 @@ write_captions <- function(dat, # converted model output object
'landings.max' = as.character(landings.max),

## natural mortality (M)
# 'M.age.min' = as.character(M.age.min),
# 'M.age.max' = as.character(M.age.max),
'M.age.min' = as.character(M.age.min),
'M.age.max' = as.character(M.age.max),
# 'M.rate.min' = as.character(M.rate.min),
# 'M.rate.max' = as.character(M.rate.max),

Expand Down

0 comments on commit 2d42cf1

Please sign in to comment.