A wrapper around dplyr::mutate() that creates a correction factor for each observation.

dr_factor(.data, corrFactor, dateVar, timeVar, tz = NULL,
    format = c("MDY", "YMD"), keepDateTime = TRUE)

Arguments

.data

A tbl

corrFactor

New variable name for correction factor data

dateVar

Name of variable containing date data

timeVar

Name of variable containing time data

tz

String name of timezone, defaults to system's timezone

format

Either "MDY" or "YMD" for dateVar - deprecated as of driftR v1.1

keepDateTime

A logical statement to keep an intermediate dateTime variable

Value

An object of the same class as .data with the new correction factor variable added to the other data in .data as well as a dateTime variable if keepDateTime = TRUE.

Details

Correction factors are calculated based on the time of the observation and the total amount of time that the instrument had been deployed. They are used in the equations for both the one-point and two-point drift corrections.

See also

dr_correctOne for correction factor creation, dr_correctTwo for the two-point drift correction

Examples

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), stringsAsFactors = FALSE ) dr_factor(testData, corrFactor = corrFac, dateVar = Date, timeVar = Time, keepDateTime = TRUE)
#> Date Time Temp SpCond dateTime corrFac #> 1 9/18/2015 12:10:49 14.76 0.754 9/18/2015 12:10:49 0.0000000 #> 2 9/18/2015 12:15:50 14.64 0.750 9/18/2015 12:15:50 0.2003995 #> 3 9/18/2015 12:20:51 14.57 0.750 9/18/2015 12:20:51 0.4007989 #> 4 9/18/2015 12:25:51 14.51 0.749 9/18/2015 12:25:51 0.6005326 #> 5 9/18/2015 12:30:51 14.50 0.749 9/18/2015 12:30:51 0.8002663 #> 6 9/18/2015 12:35:51 14.63 0.749 9/18/2015 12:35:51 1.0000000