SmoothTimeSeries: Clean a time series

View source: R/SmoothTimeSeries.R

SmoothTimeSeriesR Documentation

Clean a time series

Description

Smooth out time series data using a median and then a mean filter over specified windows of time.

Usage

SmoothTimeSeries(
  data,
  id_col = NULL,
  param_col,
  var_col,
  time_col,
  median_mins = NULL,
  mean_mins = NULL,
  n_sec_per_row = 5,
  k1 = NULL,
  k2 = NULL
)

Arguments

data

the input data frame

id_col

name of column, passed as a string, to identify observations by, e.g., a patient identifier

param_col

name of column, as string, specifying names of parameters to perform smoothing for.

var_col

string name of column containing the values for the parameters specified in param_col

time_col

the column containing the timestamps passed as a string

median_mins

window length of data in minutes to perform the median filtering on

mean_mins

window length of data in minutes to perform the mean filtering on

n_sec_per_row

Length of time in seconds that each row of data corresponds to. Defaults to 5 for BedMaster data.

k1

number of rows to perform median filter on. Only used if the same amount of time does not pass between each row and median_mins is not specified

k2

number of rows to perform mean filter on. Only used if the same amount of time does not pass between each row and mean_mins is not specified

Examples

median_mins = 3
mean_mins = 5

tstdat2 <- SmoothTimeSeries(data = tstdat,
                            id_col = "PATIENT_ID",
                            param_col = "ParName",
                            var_col = "ParValue",
                            time_col = "ParTime",
                            median_mins = median_mins,
                            mean_mins = mean_mins)

kwdoyle/kevtools documentation built on Jan. 4, 2023, 10:32 p.m.