From ac9bdd925ec130c63717f8bd862ca02b132e4e25 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 23 Jan 2025 14:13:08 -0500 Subject: [PATCH] Updated calculation for landings plot's y axis max, since it's a stacked area plot --- R/write_captions.R | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/R/write_captions.R b/R/write_captions.R index 00b5410..3b7ad96 100644 --- a/R/write_captions.R +++ b/R/write_captions.R @@ -263,8 +263,13 @@ write_captions <- function(dat, # converted model output object # t.series is associated with a conversion from BAM output and CATCH with SS3 converted output !is.na(fleet) ) |> - dplyr::slice(which.max(estimate)) |> - dplyr::select(estimate) |> + dplyr::group_by(fleet, year) |> + dplyr::summarise(max_est = max(estimate)) |> + dplyr::filter(!is.na(max_est)) |> + dplyr::group_by(year) |> + dplyr::summarise(max_est_yr = sum(max_est)) |> + dplyr::slice(which.max(max_est_yr)) |> + dplyr::select(max_est_yr) |> as.numeric() |> round(digits = 2)