A wrapper around dplyr::mutate()
that creates a corrected value for each observation of the
specified variable based on one data point.
dr_correctOne(.data, sourceVar, cleanVar, calVal, calStd, factorVar)
.data | A tbl |
---|---|
sourceVar | Name of variable to correct |
cleanVar | New variable name for corrected data |
calVal | A numeric value; the value that the instrument was actually reading for the parameter |
calStd | A numeric value; the value that the instrument should have been reading for that standard; i.e. the standard value |
factorVar | Name of variable generated using |
An object of the same class as .data
with the new corrected variable added
to the other data in .data
.
This function takes the raw data from the water-quality instrument, utilizes the values generated from
dr_factor
and returns data that accounts for drift over time. This is done via a one-point
calibration standard, which it typical for specific conductivity, dissolved oxygen, and turbidity.
dr_factor
for correction factor creation,
dr_correctTwo
for the two-point drift correction
testData <- data.frame( Date = c("9/18/2015", "9/18/2015", "9/18/2015", "9/18/2015", "9/18/2015", "9/18/2015"), Time = c("12:10:49", "12:15:50", "12:20:51", "12:25:51", "12:30:51", "12:35:51"), Temp = c(14.76, 14.64, 14.57, 14.51, 14.50, 14.63), SpCond = c(0.754, 0.750, 0.750, 0.749, 0.749, 0.749), corrFac = c(0.0000000, 0.2003995, 0.4007989, 0.6005326, 0.8002663, 1.0000000), stringsAsFactors = FALSE ) dr_correctOne(testData, sourceVar = SpCond, cleanVar = SpCond_Corr, calVal = 1.05, calStd = 1, factorVar = corrFac)#> Date Time Temp SpCond corrFac SpCond_Corr #> 1 9/18/2015 12:10:49 14.76 0.754 0.0000000 0.7540000 #> 2 9/18/2015 12:15:50 14.64 0.750 0.2003995 0.7600200 #> 3 9/18/2015 12:20:51 14.57 0.750 0.4007989 0.7700399 #> 4 9/18/2015 12:25:51 14.51 0.749 0.6005326 0.7790266 #> 5 9/18/2015 12:30:51 14.50 0.749 0.8002663 0.7890133 #> 6 9/18/2015 12:35:51 14.63 0.749 1.0000000 0.7990000