Skip to content

Commit

Permalink
fix: Adds add = TRUE, after = FALSE to on.exit()
Browse files Browse the repository at this point in the history
  • Loading branch information
kellijohnson-NOAA committed Jul 3, 2023
1 parent b2c3422 commit 560769a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion R/EF1_Denominator.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ EF1_Denominator <- function(Pdata,
plot <- file.path(savedir, "PacFIN_exp1_denom.png")
plot2 <- file.path(savedir, "PacFIN_WL.png")
grDevices::png(plot)
on.exit(grDevices::dev.off(), add = TRUE)
on.exit(grDevices::dev.off(), add = TRUE, after = FALSE)
}
graphics::par(mfrow = c(1, ifelse(nNA > 0, 2, 1)), mgp = c(2.5, 0.5, 0))
graphics::boxplot(
Expand Down
2 changes: 1 addition & 1 deletion R/age_representativeness_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ age_representativeness_plot <- function(bio,
plot_panels = c(10, 2),
wait2plot = FALSE) {
if (!is.null(file)) {
on.exit(grDevices::dev.off(), add = TRUE)
on.exit(grDevices::dev.off(), add = TRUE, after = FALSE)
}
if (!is.null(file)) wait2plot <- FALSE

Expand Down
2 changes: 1 addition & 1 deletion R/cleanPacFIN.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ cleanPacFIN <- function(Pdata,
Pdata$year <- Pdata$SAMPLE_YEAR
if (!missing(savedir)) {
grDevices::png(filename = file.path(savedir, "PacFIN_comp_season.png"))
on.exit(grDevices::dev.off(), add = TRUE)
on.exit(grDevices::dev.off(), add = TRUE, after = FALSE)
}
Pdata <- getSeason(Pdata, verbose = verbose,
plotResults = !missing(savedir))
Expand Down
2 changes: 1 addition & 1 deletion R/doSexRatio.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ doSexRatio <- function(CompData,
if (!missing(savedir)) {
find = which(CompData$usamps > 0 )
grDevices::png(file.path(savedir, "Applied_Sex_Ratio_to_Unsexed_Fish.png"))
on.exit(grDevices::dev.off(), add = TRUE)
on.exit(grDevices::dev.off(), add = TRUE, after = FALSE)
plot(CompData[find,'lengthcm'], CompData[find, 'sexRatio'],
xlab = "Length (cm)", ylab = "Sex Ratio",
main = paste0("Sex Ratio Applied to Unsexed Fish (N = ", sum(CompData$usamps), ")" )
Expand Down
2 changes: 1 addition & 1 deletion R/getDB.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ getDB <- function(sql,
uid = username,
pw = password
)
on.exit(RODBC::odbcClose(database))
on.exit(RODBC::odbcClose(database), add = TRUE, after = FALSE)
out <- tryCatch(
RODBC::sqlQuery(database, sql, as.is = asis),
error = function(e) e
Expand Down
4 changes: 2 additions & 2 deletions R/getExpansion_2.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ getExpansion_2 <- function(Pdata,
NA_EF2[, "FREQ"] <- 1
if (!missing(savedir)) {
grDevices::png(file.path(savedir, "PacFIN_exp2_NAreplace.png"))
on.exit(grDevices::dev.off(), add = TRUE)
on.exit(grDevices::dev.off(), add = TRUE, after = FALSE)
graphics::barplot(
stats::xtabs(NA_EF2$FREQ ~ NA_EF2$state + NA_EF2$fishyr),
col = grDevices::rainbow(3),
Expand All @@ -223,7 +223,7 @@ getExpansion_2 <- function(Pdata,

if (!missing(savedir)) {
grDevices::png(file.path(savedir, "PacFIN_exp2_summarybyyear.png"))
on.exit(grDevices::dev.off(), add = TRUE)
on.exit(grDevices::dev.off(), add = TRUE, after = FALSE)
graphics::boxplot(Pdata$Expansion_Factor_2 ~ Pdata$fishyr,
main = "", xlab = "Year", ylab = "Second-stage expansion factor")
}
Expand Down
10 changes: 5 additions & 5 deletions R/plotCleaned.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ plotCleaned <- function (Pdata,

#### Plot
grDevices::png(file.path(savedir, "PacFIN_comp_Nbystate.png"))
on.exit(grDevices::dev.off(), add = TRUE)
on.exit(grDevices::dev.off(), add = TRUE, after = FALSE)
graphics::par(mfrow = c(2, 1),
oma = c(1, 1, 3, 0.25), mar = c(0.5, 3.25, 0, 0),
mgp = c(1.5, 0.5, 0))
Expand All @@ -52,7 +52,7 @@ plotCleaned <- function (Pdata,
args.legend = list(x = "topleft", bty = "n"))

grDevices::png(file.path(savedir, "PacFIN_comp_distributions.png"))
on.exit(grDevices::dev.off(), add = TRUE)
on.exit(grDevices::dev.off(), add = TRUE, after = FALSE)
graphics::par(mfrow = c(2, 1),
oma = c(1, 1, 3, 0.25), mar = c(0.5, 3.25, 0, 0),
mgp = c(1.5, 0.5, 0))
Expand All @@ -64,7 +64,7 @@ plotCleaned <- function (Pdata,
frame.plot = TRUE, ylim = c(0, max(Pdata$Age, na.rm = TRUE)))

grDevices::png(file.path(savedir, "PacFIN_comp_NbyGRID.png"))
on.exit(grDevices::dev.off(), add = TRUE)
on.exit(grDevices::dev.off(), add = TRUE, after = FALSE)
graphics::par(mfrow = c(2, 1),
oma = c(1, 1, 3, 0.25), mar = c(0.5, 3.25, 0, 0),
mgp = c(1.5, 0.5, 0))
Expand All @@ -82,14 +82,14 @@ plotCleaned <- function (Pdata,

if (!all(is.na(Pdata[, "DEPTH_AVG"]))) {
grDevices::png(file.path(savedir, "PacFIN_comp_depth.png"))
on.exit(grDevices::dev.off(), add = TRUE)
on.exit(grDevices::dev.off(), add = TRUE, after = FALSE)
graphics::boxplot(Pdata$DEPTH_AVG ~ Pdata$fishyr, ylab = expression(bar(Depth)),
frame.plot = FALSE, ylim = c(0, max(Pdata$DEPTH_AVG, na.rm = TRUE)))
}

if (geargroups) {
grDevices::png(file.path(savedir, "PacFIN_comp_geargroup.png"))
on.exit(grDevices::dev.off(), add = TRUE)
on.exit(grDevices::dev.off(), add = TRUE, after = FALSE)
graphics::par(mfrow = c(2, 1),
oma = c(1, 1, 3, 0.25), mar = c(0.5, 3.25, 0, 0),
mgp = c(1.5, 0.5, 0))
Expand Down

0 comments on commit 560769a

Please sign in to comment.