Description Usage Arguments Value Examples
View source: R/be_lag_difference.R
Calculate differences for the dependent and independent variables and remove any NA values. This modifies the data.table in place.
1 2 | lag_difference(dat, var_name = "wl", lag_space = 1, inverse = FALSE,
remove_na = TRUE)
|
dat |
data that has the independent and dependent variables (data.table) |
var_name |
name of the column to lag (character) |
lag_space |
space between difference calculation in number of observations |
inverse |
whether the barometric relationship is inverse (TRUE means that when the barometric pressure goes up the measured water level goes down (vented transducer, depth to water), FALSE means that when the barometric pressure goes up so does the measured pressure (non-vented transducer)) (logical). |
remove_na |
remove NA values (logical) |
data.table with lagged differences
1 2 3 4 5 6 7 | library(data.table)
datetime <- seq.POSIXt(as.POSIXct("2016-01-01 12:00:00"),
as.POSIXct("2016-01-05 12:00:00"), by='hour' )
baro <- sin(seq(0, 2*pi, length.out = length(datetime)))
wl <- 0.4 * baro
dat <- data.table(baro, wl, datetime)
lag_difference(dat, lag_space = 1, remove_na = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.