Skip to content

Commit

Permalink
v2.0.7.9023
Browse files Browse the repository at this point in the history
* refactor: Update stats plots with legend
    + fun.Stats.R
    + fun.Stats.File.R
  • Loading branch information
leppott committed Sep 22, 2023
1 parent 5d6c442 commit 13d46ef
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ContDataQC
Title: Quality Control (QC) of Continous Monitoring Data
Version: 2.0.7.9022
Version: 2.0.7.9023
Authors@R: c(
person("Erik W", "Leppo", email="Erik.Leppo@tetratech.com",role=c("aut","cre")),
person("Ann","Roseberry Lincoln", role="ctb"),
Expand Down
10 changes: 9 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ NEWS-ContDataQC

<!-- NEWS.md is generated from NEWS.Rmd. Please edit that file -->

#> Last Update: 2023-09-18 08:25:37.45011
#> Last Update: 2023-09-22 16:14:21.634179

# Version History

## v2.0.7.9023

2023-09-18

- refactor: Update stats plots with legend
- fun.Stats.R
- fun.Stats.File.R

## v2.0.7.9022

2023-09-18
Expand Down
10 changes: 9 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ NEWS-ContDataQC

<!-- NEWS.md is generated from NEWS.Rmd. Please edit that file -->

#> Last Update: 2023-09-18 08:25:37.45011
#> Last Update: 2023-09-22 16:14:21.634179

# Version History

## v2.0.7.9023

2023-09-18

- refactor: Update stats plots with legend
- fun.Stats.R
- fun.Stats.File.R

## v2.0.7.9022

2023-09-18
Expand Down
7 changes: 7 additions & 0 deletions NEWS.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ cat(paste0("Last Update: ",Sys.time()))

# Version History

## v2.0.7.9023
2023-09-18

* refactor: Update stats plots with legend
+ fun.Stats.R
+ fun.Stats.File.R

## v2.0.7.9022
2023-09-18

Expand Down
86 changes: 82 additions & 4 deletions R/fun.Stats.File.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ fun.Stats.File <- function(fun.myFile
, fun.myReport.format
, fun.myReport.Dir
) {##FUN.fun.Stats.START

# par
par.orig <- par(no.readonly = TRUE) # save original par settings
leg_inset <- c(0, -0.25)

#
# ##
# # QC (from fun.Master.R)
Expand Down Expand Up @@ -465,14 +470,15 @@ fun.Stats.File <- function(fun.myFile
# print(paste0("QC.Section: ",qc.section))
# flush.console()
#
#

# Save plots as PDF ####
strFile.Prefix.Out <- fun.myProcedure.Step
strFile.plot <- paste(paste(strFile.Prefix.Out,strFile.Base,i,sep=ContData.env$myDelim),"pdf",sep=".")
#pdf(file=paste(myDir.data.export,strFile.plot,sep="/"),width=11,height=8.5)
grDevices::pdf(file=file.path(myDir.data.export,strFile.plot),width=11,height=8.5)


# Add extra space to right of plot area
par(mar = c(10, 4.1, 4.1, 2))

## Daily
myTimeFrame <- "day"
Expand Down Expand Up @@ -522,6 +528,16 @@ fun.Stats.File <- function(fun.myFile
myAT <- c(1,round(n.Total * pct,0))
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()

## Julian Day
Expand Down Expand Up @@ -565,6 +581,16 @@ fun.Stats.File <- function(fun.myFile
myAT <- c(1,round(n.Total * pct,0))
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()

## Year_Month
Expand Down Expand Up @@ -603,6 +629,16 @@ fun.Stats.File <- function(fun.myFile
myAT <- seq_len(n.Total)
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()
#

Expand Down Expand Up @@ -646,6 +682,16 @@ fun.Stats.File <- function(fun.myFile
myAT <- seq_len(n.Total)
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()
#
## Year_Season
Expand Down Expand Up @@ -684,6 +730,16 @@ fun.Stats.File <- function(fun.myFile
myAT <- seq_len(n.Total)
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1, at=myAT, labels=myLab, tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()
#
#
Expand Down Expand Up @@ -723,6 +779,16 @@ fun.Stats.File <- function(fun.myFile
myAT <- seq_len(n.Total)
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1, at=myAT, labels=myLab, tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()
#
## Year
Expand Down Expand Up @@ -761,14 +827,22 @@ fun.Stats.File <- function(fun.myFile
myAT <- seq_len(n.Total)
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()
#
#

grDevices::dev.off()##PDF.END



# Combine (all the same so just rbind)
stats.i.ALL <- rbind(stats.i.y, stats.i.s, stats.i.ys, stats.i.m, stats.i.ym, stats.i.jd, stats.i.d)
stats.i.ALL[,ContData.env$myName.SiteID] <- strFile.Base # fun.myData.SiteID
Expand All @@ -793,6 +867,10 @@ fun.Stats.File <- function(fun.myFile

#
}##FOR.i.END

# par
#par(par.orig) # return to original par settings

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Run QC Report
Expand Down
87 changes: 84 additions & 3 deletions R/fun.Stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ fun.Stats <- function(fun.myData.SiteID
# global variable bindings ----
Selection.Type <- myDir.BASE <- Selection.SUB <- NULL

# par
par.orig <- par(no.readonly = TRUE) # save original par settings
leg_inset <- c(0, -0.25)

#
# ##
# # QC (from fun.Master.R)
Expand Down Expand Up @@ -489,13 +493,16 @@ fun.Stats <- function(fun.myData.SiteID
# print(paste0("QC.Section: ",qc.section))
# flush.console()
#
#

# Save plots as PDF
strFile.Prefix.Out <- fun.myProcedure.Step
strFile.plot <- paste(paste(strFile.Prefix.Out,strFile.SiteID,fun.myData.Type,strFile.Date.Start,strFile.Date.End,i,sep=ContData.env$myDelim),"pdf",sep=".")
#pdf(file=paste(myDir.data.export,strFile.plot,sep="/"),width=11,height=8.5)
grDevices::pdf(file=file.path(myDir.data.export,strFile.plot),width=11,height=8.5)

# Add extra space to right of plot area
par(mar = c(10, 4.1, 4.1, 2))

## Daily
myTimeFrame <- "day"
myTF.Field <- ContData.env$myName.Date
Expand Down Expand Up @@ -543,6 +550,17 @@ fun.Stats <- function(fun.myData.SiteID
myAT <- c(1,round(n.Total * pct,0))
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)

legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()

## Julian Day
Expand Down Expand Up @@ -581,6 +599,16 @@ fun.Stats <- function(fun.myData.SiteID
myAT <- c(1,round(n.Total * pct,0))
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()

## Year_Month
Expand Down Expand Up @@ -618,6 +646,16 @@ fun.Stats <- function(fun.myData.SiteID
myAT <- seq_len(n.Total)
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()
#

Expand Down Expand Up @@ -656,6 +694,16 @@ fun.Stats <- function(fun.myData.SiteID
myAT <- seq_len(n.Total)
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()
#
## Year_Season
Expand Down Expand Up @@ -693,6 +741,16 @@ fun.Stats <- function(fun.myData.SiteID
myAT <- seq_len(n.Total)
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()
#
#
Expand Down Expand Up @@ -731,6 +789,16 @@ fun.Stats <- function(fun.myData.SiteID
myAT <- seq_len(n.Total)
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()
#
## Year
Expand Down Expand Up @@ -768,14 +836,22 @@ fun.Stats <- function(fun.myData.SiteID
myAT <- seq_len(n.Total)
myLab <- stats.i[,"TimeValue"][myAT]
graphics::axis(1,at=myAT,labels=myLab,tick=TRUE)
legend("bottom"
, legend = c("mean", "Range (min, max)")
, col = c("black", "gray")
, lty = c("solid", NA)
, pch = c(NA, 15)
, pt.cex = 2
, bty = "n"
, inset = leg_inset
, xpd = TRUE
)# legend
#dev.off()
#
#

grDevices::dev.off()##PDF.END



# Combine (all the same so just rbind)
stats.i.ALL <- rbind(stats.i.y, stats.i.s, stats.i.ys, stats.i.m, stats.i.ym, stats.i.jd, stats.i.d)
stats.i.ALL[,ContData.env$myName.SiteID] <- fun.myData.SiteID
Expand All @@ -799,6 +875,11 @@ fun.Stats <- function(fun.myData.SiteID

#
}##FOR.i.END


# par
#par(par.orig) # return to original par settings

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Run QC Report
Expand Down
Loading

0 comments on commit 13d46ef

Please sign in to comment.