|
| 1 | +#' Quality Control of Raw Data |
| 2 | +#' |
| 3 | +#' Graphical quality control tests of temperature and oxygen raw data before and after correction for background respiration |
| 4 | +#' |
| 5 | +#' @usage |
| 6 | +#' QC.meas(clean.data, |
| 7 | +#' QC = c("Temperature", |
| 8 | +#' "Total.O2.phases", |
| 9 | +#' "Corrected.O2.phases", |
| 10 | +#' "Total.O2.chambers", |
| 11 | +#' "Corrected.O2.chambers")) |
| 12 | +#' |
| 13 | +#' @param clean.data a data frame obtained by using the function \code{\link{correct.meas}} |
| 14 | +#' @param QC string: the name of a visual QC test. Five options are available: |
| 15 | +#' \itemize{ |
| 16 | +#' \item "Temperature": a graph of temperature vs. time ordered by chambers |
| 17 | +#' \item "Total.O2.chambers": a graph of dissolved oxygen vs. time ordered by chambers |
| 18 | +#' \item "Total.O2.phases": a graph of dissolved oxygen vs. time ordered by chambers and phases |
| 19 | +#' \item "Corrected.O2.chambers": a graph of dissolved oxygen corrected for background respiration vs. time ordered by chambers |
| 20 | +#' \item "Corrected.O2.phases": a graph of dissolved oxygen corrected for background respiration vs. time ordered by chambers and phases |
| 21 | +#' } |
| 22 | +#' |
| 23 | +#' @importFrom lattice xyplot |
| 24 | +#' @importFrom grDevices dev.new |
| 25 | +#' @importFrom graphics abline legend par plot |
| 26 | +#' @importFrom stats coef lm predict.lm |
| 27 | +#' @importFrom utils head read.table tail write.table |
| 28 | +#' |
| 29 | +#' @examples |
| 30 | +#' \dontrun{ |
| 31 | +#' # if the data have been already loaded to R, |
| 32 | +#' # skip the first line of the code: |
| 33 | +#' data(SMR.clean) |
| 34 | +#' |
| 35 | +#' QC.meas(SMR.clean, "Temperature") |
| 36 | +#' QC.meas(SMR.clean, "Total.O2.phases") |
| 37 | +#' QC.meas(SMR.clean, "Corrected.O2.phases") |
| 38 | +#' QC.meas(SMR.clean, "Total.O2.chambers") |
| 39 | +#' QC.meas(SMR.clean, "Corrected.O2.chambers") |
| 40 | +#' } |
| 41 | +#' @export |
| 42 | + |
| 43 | +QC.meas <- function(clean.data, |
| 44 | + QC = c("Temperature", "Total.O2.phases", "Corrected.O2.phases", |
| 45 | + "Total.O2.chambers", "Corrected.O2.chambers")){ |
| 46 | + |
| 47 | + if (QC == "Temperature"){ |
| 48 | + return(xyplot(Temp~Time|Phase*Chamber.No, data=clean.data, |
| 49 | + par.strip.text=list(cex=0.6), cex=0.5, |
| 50 | + xlab = "Time (s)", ylab = bquote("Temperature (" ~ C^o ~ ")"), as.table = T, |
| 51 | + scales=list(tck=c(1,0), x=list(cex=0.7), y=list(cex=0.7)))) |
| 52 | + } |
| 53 | + else if (QC == "Total.O2.phases"){ |
| 54 | + return(xyplot(O2~Time|Phase*Chamber.No, data=clean.data, |
| 55 | + par.strip.text=list(cex=0.6), cex=0.5, |
| 56 | + xlab = "Time (s)", ylab = paste("DO (", clean.data$DO.unit[1], "/L)", sep = ""), as.table = T, |
| 57 | + scales=list(tck=c(1,0), x=list(cex=0.7), y=list(cex=0.7)))) |
| 58 | + } |
| 59 | + |
| 60 | + else if (QC == "Corrected.O2.phases"){ |
| 61 | + return(xyplot(O2.correct~Time|Phase*Chamber.No, data=clean.data, |
| 62 | + par.strip.text=list(cex=0.6), cex=0.5, |
| 63 | + xlab = "Time (s)", ylab = paste("DO (", clean.data$DO.unit[1], "/L)", sep = ""), as.table = T, |
| 64 | + scales=list(tck=c(1,0), x=list(cex=0.7), y=list(cex=0.7)))) |
| 65 | + } |
| 66 | + |
| 67 | + else if (QC == "Total.O2.chambers"){ |
| 68 | + return(xyplot(O2~Date.Time|Chamber.No, data=clean.data, cex=0.5, |
| 69 | + xlab = "Time", ylab = paste("DO (", clean.data$DO.unit[1], "/L)", sep = ""), as.table = T)) |
| 70 | + } |
| 71 | + |
| 72 | + else if (QC == "Corrected.O2.chambers"){ |
| 73 | + return(xyplot(O2.correct~Date.Time|Chamber.No, data=clean.data, cex=0.5, |
| 74 | + xlab = "Time", ylab = paste("DO (", clean.data$DO.unit[1], "/L)", sep = ""), as.table = T)) |
| 75 | + } |
| 76 | + |
| 77 | + else |
| 78 | + { |
| 79 | + print ("This quality test does not exist! Please, choose among avaliable variants: Temperature, Total.O2.chambers, Total.O2.phases, Corrected.O2.chambers or Corrected.O2.phases") |
| 80 | + } |
| 81 | +} |
0 commit comments