Skip to content

Commit

Permalink
Merge pull request #111 from PIFSCstockassessments/fix-109-r4ss-depen…
Browse files Browse the repository at this point in the history
…dency

gh::gh NA_character token; r4ss 1.49.3 dependency
  • Loading branch information
efletcherPIFSC authored Nov 16, 2024
2 parents 98ea41e + 83dd51d commit fb78e74
Show file tree
Hide file tree
Showing 16 changed files with 300 additions and 26 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ Depends:
R (>= 3.5)
Imports:
dplyr,
gh,
gplots,
lifecycle,
magrittr,
mvtnorm,
r4ss (>= 1.46.1),
r4ss (== 1.49.3),
randtests,
reshape2,
rlang
Expand All @@ -34,9 +35,9 @@ Suggests:
rmarkdown,
testthat (>= 3.0.0)
Remotes:
r4ss/r4ss@main
r4ss/r4ss@v1.49.3
Encoding: UTF-8
LazyData: True
LazyDataCompression: gzip
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export(SSretroComps)
export(SSrmse)
export(SSrunstest)
export(SSsettingsBratioF)
export(get_ss3_exe)
export(ssruns_sig3)
import(gh)
importFrom(gplots,ci2d)
importFrom(grDevices,adjustcolor)
importFrom(grDevices,dev.new)
Expand Down
2 changes: 1 addition & 1 deletion R/SSdeltaMVLN_old.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' A function to generate kobe pdfs from a Multivariate Log-Normal Distribution including plotting option. This version is used for older versions of Stock Synthesis. For newer versions (v3.24 and newer), use SSdeltaMVLN().
#'
#'
#' @param ss3rep from r4ss::SSgetoutput()$replist1
#' @param ss3rep from r4ss::SSgetoutput()[["replist1"]]
#' @param status covarying stock status quantaties to extract from Hessian
#' @param quants additional stock quantaties to extract from Hessian
#' @param Fref Choice of reference point for stock SSB/XFref=c("MSY","Ftrg"),only if F_report_basis: 0 or 3
Expand Down
2 changes: 1 addition & 1 deletion R/SSkobe.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Generates a Kobe plot or phase plot illustrating the stock status uncertainty over SSB/SSBmsy and F/Fmsy
#'
#' @param kb output from SSdeltaMVLN()$kb
#' @param kb output from SSdeltaMVLN()[["kb"]]
#' @param joint option FALSE shows individual runs
#' @param year option to choose year for kobe, last year is default
#' @param posterior visualization of posterior c("points","kernel")
Expand Down
6 changes: 3 additions & 3 deletions R/SSplotEnsemble.R
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ SSplotEnsemble <- function(kb,
n.quantiles <- length(quantiles)
for (i in 1:n.quantiles) {
exp[[i]] <- aggregate(y ~ year + run, kb, mean)
exp[[i]][["lower"]] <- aggregate(y ~ year + run, kb, quantile, quantiles[[i]][1])$y
exp[[i]][["upper"]] <- aggregate(y ~ year + run, kb, quantile, quantiles[[i]][2])$y
exp[[i]][["lower"]] <- aggregate(y ~ year + run, kb, quantile, quantiles[[i]][1])[["y"]]
exp[[i]][["upper"]] <- aggregate(y ~ year + run, kb, quantile, quantiles[[i]][2])[["y"]]
}


Expand Down Expand Up @@ -444,7 +444,7 @@ ensemble_plot_index <- function(summaryoutput,
# legendloc <- "topleft"
# }
# if (is.numeric(legendloc)) {
# Usr <- par()$usr
# Usr <- par()[["usr"]]
# legendloc <- list(
# x = Usr[1] + legendloc[1] * (Usr[2] - Usr[1]),
# y = Usr[3] + legendloc[2] * (Usr[4] - Usr[3])
Expand Down
6 changes: 3 additions & 3 deletions R/SSplotHCxval.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ SSplotHCxval <- function(retroSummary,
# legendloc <- "topleft"
# }
# if (is.numeric(legendloc)) {
# Usr <- par()$usr
# Usr <- par()[["usr"]]
# legendloc <- list(
# x = Usr[1] + legendloc[1] * (Usr[2] - Usr[1]),
# y = Usr[3] + legendloc[2] * (Usr[4] - Usr[3])
Expand Down Expand Up @@ -613,7 +613,7 @@ SSplotHCxval <- function(retroSummary,
filenameprefix = filenameprefix
)
par(par)
get_mase <- plot_hcxval(indexfleets)$MASE
get_mase <- plot_hcxval(indexfleets)[["MASE"]]
dev.off()
MASE <- rbind(MASE, get_mase)
} # End of Fleet Loop
Expand All @@ -626,7 +626,7 @@ SSplotHCxval <- function(retroSummary,
if (fi %in% legendindex) legend <- TRUE
indexfleets <- unique(hcruns[["indices"]][["Fleet"]])[fi]
if (!add) (par)
get_mase <- plot_hcxval(indexfleets)$MASE
get_mase <- plot_hcxval(indexfleets)[["MASE"]]
MASE <- rbind(MASE, get_mase)
} # End of Fleet Loop
}
Expand Down
4 changes: 2 additions & 2 deletions R/SSplotModelcomp.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ SSplotModelcomp <- function(summaryoutput,
# legendloc <- "topleft"
# }
# if (is.numeric(legendloc)) {
# Usr <- par()$usr
# Usr <- par()[["usr"]]
# legendloc <- list(
# x = Usr[1] + legendloc[1] * (Usr[2] - Usr[1]),
# y = Usr[3] + legendloc[2] * (Usr[4] - Usr[3])
Expand Down Expand Up @@ -510,7 +510,7 @@ SSplotModelcomp <- function(summaryoutput,
# legendloc <- "topleft"
# }
# if (is.numeric(legendloc)) {
# Usr <- par()$usr
# Usr <- par()[["usr"]]
# legendloc <- list(
# x = Usr[1] + legendloc[1] * (Usr[2] - Usr[1]),
# y = Usr[3] + legendloc[2] * (Usr[4] - Usr[3])
Expand Down
2 changes: 1 addition & 1 deletion R/SSplotRetro.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ SSplotRetro <- function(summaryoutput,
# legendloc <- "topleft"
# }
# if (is.numeric(legendloc)) {
# Usr <- par()$usr
# Usr <- par()[["usr"]]
# legendloc <- list(
# x = Usr[1] + legendloc[1] * (Usr[2] - Usr[1]),
# y = Usr[3] + legendloc[2] * (Usr[4] - Usr[3])
Expand Down
8 changes: 4 additions & 4 deletions R/SSplotRunstest.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ SSplotRunstest <- function(ss3rep,
}

if (subplots == "len" | subplots == "age" | subplots == "size") {
comps <- SScompsTA1.8(ss3rep, fleet = NULL, type = subplots, plotit = FALSE)$runs_dat
comps <- SScompsTA1.8(ss3rep, fleet = NULL, type = subplots, plotit = FALSE)[["runs_dat"]]
comps[["residuals"]] <- ifelse(is.na(comps[["Obs"]]), NA, log(comps[["Obs"]]) - log(comps[["Exp"]]))
if (is.null(comps[["Fleet_name"]])) { # Deal with Version control
comps[["Fleet_name"]] <- comps[["Name"]]
Expand All @@ -207,7 +207,7 @@ SSplotRunstest <- function(ss3rep,
}

if (subplots == "con") {
cond <- SScompsTA1.8(ss3rep, fleet = NULL, type = subplots, plotit = FALSE)$runs_dat
cond <- SScompsTA1.8(ss3rep, fleet = NULL, type = subplots, plotit = FALSE)[["runs_dat"]]
cond[["residuals"]] <- ifelse(is.na(cond[["Obs"]]), NA, log(cond[["Obs"]]) - log(cond[["Exp"]]))
if (is.null(cond[["Fleet_name"]])) { # Deal with Version control
cond[["Fleet_name"]] <- cond[["Name"]]
Expand Down Expand Up @@ -444,7 +444,7 @@ SSrunstest <- function(ss3rep,
}

if (subplots == "len" | subplots == "age") {
comps <- SScompsTA1.8(ss3rep, fleet = NULL, type = subplots, plotit = FALSE)$runs_dat
comps <- SScompsTA1.8(ss3rep, fleet = NULL, type = subplots, plotit = FALSE)[["runs_dat"]]
comps[["residuals"]] <- ifelse(is.na(comps[["Obs"]]), NA, log(comps[["Obs"]]) - log(comps[["Exp"]]))
if (is.null(comps[["Fleet_name"]])) { # Deal with Version control
comps[["Fleet_name"]] <- comps[["Name"]]
Expand All @@ -453,7 +453,7 @@ SSrunstest <- function(ss3rep,
}

if (subplots == "con") {
cond <- SScompsTA1.8(ss3rep, fleet = NULL, type = subplots, plotit = FALSE)$runs_dat
cond <- SScompsTA1.8(ss3rep, fleet = NULL, type = subplots, plotit = FALSE)[["runs_dat"]]
cond[["residuals"]] <- ifelse(is.na(cond[["Obs"]]), NA, log(cond[["Obs"]]) - log(cond[["Exp"]]))
if (is.null(cond[["Fleet_name"]])) { # Deal with Version control
cond[["Fleet_name"]] <- cond[["Name"]]
Expand Down
6 changes: 3 additions & 3 deletions R/SSretroComps.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SSretroComps <- function(retroModels) {
rep.temp <- retroModels[[paste(replist[i])]]
rep.temp[["lendbase"]] <- rbind(rep.temp[["ghostlendbase"]], rep.temp[["lendbase"]][, 1:ncol(rep.temp[["ghostlendbase"]])])
rep.temp[["lendbase"]] <- data.frame(rep.temp[["lendbase"]], imodel = i)
lencomps <- rbind(lencomps, data.frame(SScompsTA1.8(rep.temp, type = "len", plotit = F)$runs_dat, imodel = i))
lencomps <- rbind(lencomps, data.frame(SScompsTA1.8(rep.temp, type = "len", plotit = F)[["runs_dat"]], imodel = i))
}
lencomps <- lencomps[order(lencomps[["imodel"]], lencomps[["Fleet"]], lencomps[["Time"]]), ]

Expand All @@ -42,7 +42,7 @@ SSretroComps <- function(retroModels) {
for (i in 1:length(replist)) {
rep.temp <- retroModels[[paste(replist[i])]]
rep.temp[["agedbase"]] <- rbind(rep.temp[["ghostagedbase"]], rep.temp[["agedbase"]][, 1:ncol(rep.temp[["ghostagedbase"]])])
agecomps <- rbind(agecomps, data.frame(SScompsTA1.8(rep.temp, type = "age", plotit = F)$runs_dat, imodel = i))
agecomps <- rbind(agecomps, data.frame(SScompsTA1.8(rep.temp, type = "age", plotit = F)[["runs_dat"]], imodel = i))
}
agecomps <- agecomps[order(agecomps[["imodel"]], agecomps[["Fleet"]], agecomps[["Time"]]), ]
hccomps[["age"]] <- agecomps
Expand All @@ -53,7 +53,7 @@ SSretroComps <- function(retroModels) {
for (i in 1:length(replist)) {
rep.temp <- retroModels[[paste(replist[i])]]
rep.temp[["condbase"]] <- rbind(rep.temp[["ghostcondbase"]], rep.temp[["condbase"]][, 1:ncol(rep.temp[["ghostcondbase"]])])
concomps <- rbind(concomps, data.frame(SScompsTA1.8(rep.temp, type = "con", plotit = F)$runs_dat, imodel = i))
concomps <- rbind(concomps, data.frame(SScompsTA1.8(rep.temp, type = "con", plotit = F)[["runs_dat"]], imodel = i))
}
concomps <- concomps[order(concomps[["imodel"]], concomps[["Fleet"]], concomps[["Time"]]), ]
hccomps[["con"]] <- concomps
Expand Down
4 changes: 2 additions & 2 deletions R/SSrmse.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SSrmse <- function(ss3rep, quants = c("cpue", "len", "age", "con"), seas = NULL,
}

if (quants == "len" | quants == "age" | quants == "size") {
comps <- SScompsTA1.8(ss3rep, fleet = NULL, type = quants, plotit = FALSE)$runs_dat
comps <- SScompsTA1.8(ss3rep, fleet = NULL, type = quants, plotit = FALSE)[["runs_dat"]]
comps[["residuals"]] <- ifelse(is.na(comps[["Obs"]]), NA, log(comps[["Obs"]]) - log(comps[["Exp"]]))
if (is.null(comps[["Fleet_name"]])) { # Deal with Version control
comps[["Fleet_name"]] <- comps[["Name"]]
Expand All @@ -45,7 +45,7 @@ SSrmse <- function(ss3rep, quants = c("cpue", "len", "age", "con"), seas = NULL,
}

if (quants == "con") {
cond <- SScompsTA1.8(ss3rep, fleet = NULL, type = quants, plotit = FALSE)$runs_dat
cond <- SScompsTA1.8(ss3rep, fleet = NULL, type = quants, plotit = FALSE)[["runs_dat"]]
cond[["residuals"]] <- ifelse(is.na(cond[["Obs"]]), NA, log(cond[["Obs"]]) - log(cond[["Exp"]]))
if (is.null(cond[["Fleet_name"]])) { # Deal with Version control
cond[["Fleet_name"]] <- cond[["Name"]]
Expand Down
Loading

0 comments on commit fb78e74

Please sign in to comment.