powered by
Detects potential sensor drift by comparing rolling window statistics (mean or standard deviation) to their long-term baseline. Returns a logical matrix indicating time points where the rolling statistic deviates beyond a threshold.
drift_detect(data, cols = NULL, window = 30, threshold = 3, method = c("mean", "sd"), group = NULL, date_col = NULL, verbose = FALSE)
A logical matrix with rows corresponding to observations and columns to the selected variables. TRUE indicates suspected drift.
TRUE
A data frame, matrix, or numeric vector.
Column indices or names of numeric variables. If NULL, all numeric columns are used.
NULL
Window size for rolling statistics.
Threshold in units of standard deviation. Values with absolute z-score above this are flagged as drift.
Rolling statistic to use: "mean" or "sd".
"mean"
"sd"
Optional grouping column for group-wise detection.
Optional time column (not required for calculation).
Logical; if TRUE, prints progress message.
drift_detect(data[1:500, c(1, 4, 17:19)], cols = 3:5, window = 50, threshold = 3)
Run the code above in your browser using DataLab