dataprep: Data preprocessing with multiple steps in one function

View source: R/dataprep.R

dataprepR Documentation

Data preprocessing with multiple steps in one function

Description

Performs variable deletion (varidele), observation deletion (obsedele), conditional extremum outlier removal (condextr), and short-period interpolation (shorvalu) in sequence.

Usage

dataprep(data, cols = NULL, group = NULL, optimal = FALSE,
interval = 10, times = 10, fraction = 0.25,
top = 0.995, top.error = 0.1, top.magnitude = 0.2,
bottom = 0.0025, bottom.error = 0.2, bottom.magnitude = 0.4, by = "min",
half = 30, intervals = 30, date_col = NULL, cores = NULL, verbose = FALSE)

Arguments

data

A data frame containing numeric columns and optionally a grouping column.

cols

Column indices or names of numeric variables to process.

group

Grouping column index or name.

optimal

Logical; if TRUE, optisolu is used to find optimal interval and times.

interval

Number of outlier-marking rounds between two observation-deletion rounds inside condextr.

times

Number of observation-deletion rounds in condextr.

fraction

Missing proportion threshold for variable deletion.

top, top.error, top.magnitude, bottom, bottom.error, bottom.magnitude

Outlier removal parameters.

by

Time unit for observation deletion. An invalid unit string raises an error.

half

Half window size in minutes for observation deletion.

intervals

Time gap for interpolation periods.

date_col

Time column index or name. If NULL, automatically detected.

cores

Number of CPU cores passed to obsedele(), condextr(), and optisolu(). NULL (default) lets each backend choose based on data size.

verbose

Logical; if TRUE, prints timing and deletion/interpolation counts.

Value

A preprocessed data frame.

Author(s)

Chun-Sheng Liang <chun-shengliang@qq.com>

References

1. Example data is from https://smear.avaa.csc.fi/download. It includes particle number concentrations in SMEAR I Varrio forest.

Examples

dataprep(data[1:60, c(1, 4, 18:19)], cols = 3:4, group = 2, interval = 2, times = 1, cores = 1)

dataprep documentation built on Oct. 1, 2026, 5:07 p.m.