diff --git a/DESCRIPTION b/DESCRIPTION index eef5d3f..380b89a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,16 +31,16 @@ License: MIT + file LICENSE Depends: R (>= 3.5.0) Imports: - adnuts, - cli, - glue, - lubridate, - pkgbuild, - r4ss, - remotes, - stats, - usethis, - utils + adnuts, + cli, + glue, + lubridate, + pkgbuild, + r4ss, + remotes, + stats, + usethis, + utils Suggests: devtools, TMB @@ -49,5 +49,5 @@ Remotes: github::r4ss/r4ss Encoding: UTF-8 LazyData: true -RoxygenNote: 7.3.2 Roxygen: list(markdown = TRUE) +RoxygenNote: 7.3.2 diff --git a/R/buffer_fxn.R b/R/buffer_fxn.R index 0982a56..7689e38 100644 --- a/R/buffer_fxn.R +++ b/R/buffer_fxn.R @@ -23,45 +23,43 @@ #' @author written by Chantel Wetzel #' @export #' -get_buffer <- function(years, sigma, pstar, verbose = TRUE){ - - y <- 1:(length(years) - 1) - if (sigma != 2.0) { - # the rate of change in sigma approved by the SSC in 2019 - r <- 0.075 - } else { +get_buffer <- function(years, sigma, pstar, verbose = TRUE) { + y <- 1:(length(years) - 1) + if (sigma != 2.0) { + # the rate of change in sigma approved by the SSC in 2019 + r <- 0.075 + } else { r <- 0 - } - if (verbose) { - cli::cli_inform( - "The sigma value of {sigma} adjusts yearly by the rate of {r}." - ) - } + } + if (verbose) { + cli::cli_inform( + "The sigma value of {sigma} adjusts yearly by the rate of {r}." + ) + } - # This is the equation for the rate of change in sigma - sigma_calc <- c(sigma, sigma * (1+(y-1)*r)) - buffer <- exp(stats::qnorm(pstar, 0, sigma_calc)) - max_buffer <- round(exp(stats::qnorm(pstar, 0, 2.0)), 3) - # Set the buffer for fixed catch years to 1.0 - buffer[1:2] <- 1 - category_3 <- which(buffer < max_buffer) - if (length(category_3) > 0) { - if (sigma != 2) { - if (verbose) { - cli::cli_inform( - "The buffer exceeds that category 3 buffer and is capped at {max_buffer} for + # This is the equation for the rate of change in sigma + sigma_calc <- c(sigma, sigma * (1 + (y - 1) * r)) + buffer <- exp(stats::qnorm(pstar, 0, sigma_calc)) + max_buffer <- round(exp(stats::qnorm(pstar, 0, 2.0)), 3) + # Set the buffer for fixed catch years to 1.0 + buffer[1:2] <- 1 + category_3 <- which(buffer < max_buffer) + if (length(category_3) > 0) { + if (sigma != 2) { + if (verbose) { + cli::cli_inform( + "The buffer exceeds that category 3 buffer and is capped at {max_buffer} for {years[category_3]}." - ) - } - } - buffer[category_3] <- max_buffer - } + ) + } + } + buffer[category_3] <- max_buffer + } - out <- data.frame( - year = years, - buffer = round(buffer, 3) - ) + out <- data.frame( + year = years, + buffer = round(buffer, 3) + ) - return(out) + return(out) } - diff --git a/data-raw/PacFIN_Ports_withlatlong.R b/data-raw/PacFIN_Ports_withlatlong.R index ab9e040..d65a554 100644 --- a/data-raw/PacFIN_Ports_withlatlong.R +++ b/data-raw/PacFIN_Ports_withlatlong.R @@ -15,4 +15,3 @@ pacfin_ports_withlatlong <- pacfin_ports_withlatlong_raw |> latitude = "Latitude of the port location with minutes and seconds in radians." ) usethis::use_data(pacfin_ports_withlatlong, overwrite = TRUE) -