cleanData: Clean data

Description Usage Arguments Details Value

Description

cleanData will clean and organize a data frame such that it is ready to be discretized into person-time. Its primary purpose is to make sure there are no inconsistencies with the data and to impute missing values.

Usage

1
2
cleanData(data, time = NULL, locf = TRUE, impute = TRUE,
  baseline = NULL, ignore = NULL)

Arguments

data

A data.frame object, with the ID variable in the first column.

time

Name or index of time variable (e.g. calendar date) for longitudinal data in long form. If NULL, then data is assumed to include only baseline covariates and will only impute

locf

If TRUE, all missing values will be imputed in a last observation carried forward fashion.

impute

If TRUE, all remaining missing values will be imputed using either the median (if continuous) or mode (if character or factor). This option cannot be TRUE if locf=FALSE.

baseline

A vector of baseline variable names or indicies.

ignore

Vector of covariates ignoring in the imputations

Details

This function can take data with both time-varying and baseline covariates. If locf=TRUE, then missing values will be imputed in a 'last observation carried forward' approach. Furthermore, if impute=TRUE, then remaining observations that have no value to carry forward will be imputed with the median (if continuous) or mode (if character or factor). If the data includes only baseline covariates, then only the

Value

clean returns an object of class "data.frame" with the data ordered by ID, time, and ordered column wise alphabetically.


tranlm/lrecImpact documentation built on May 31, 2019, 7:45 p.m.