Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/style-doc-code'
Browse files Browse the repository at this point in the history
  • Loading branch information
chantelwetzel-noaa committed Oct 23, 2024
2 parents f3e4641 + e8cd26a commit ae688a8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 48 deletions.
22 changes: 11 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
70 changes: 34 additions & 36 deletions R/buffer_fxn.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

1 change: 0 additions & 1 deletion data-raw/PacFIN_Ports_withlatlong.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit ae688a8

Please sign in to comment.