wideTS: Wide Time-Series Data

wideTSR Documentation

Wide Time-Series Data

Description

wideTimeSeriesLab transforms time-series data into wide format.

Usage

wideTimeSeriesLab(
  labData,
  idColName,
  labItemColName,
  windowColName,
  valueColName
)

Arguments

labData

a file or dataframe of laboratory test data with at least 4 columns about patient ID, lab item, test value and test date, respectively.

idColName

the column name that records patient ID in labData.

labItemColName

the column name that records lab item in labData. If lab code is combined by multiple columns, then just simply add + operator between column names, e.g., A + B.

windowColName

the column name that records time window sequence in labData.

Details

After setting desired time window, data can further transform into wide format, which is more suitable for analysis. If lab item code is composed by multiple columns, it will automatically combined as one. And there can only be single value column selected in this step. #'

Value

A new, wide-formatted data.table.

Examples


timeSeriesData <- getTimeSeriesLab(labData = labSample,
                                   idColName = SUBJECT_ID,
                                   labItemColName = ITEMID,
                                   dateColName = CHARTTIME,
                                   valueColName = VALUENUM,
                                   indexDate = first,
                                   gapDate = 360,
                                   completeWindows = TRUE)
imputedData <- imputeTimeSeriesLab(labData = timeSeriesData,
                                   idColName = ID,
                                   labItemColName = ITEMID,
                                   windowColName = Window,
                                   valueColName = Max & Min,
                                   impMethod = mean,
                                   imputeOverallMean=FALSE)
wideTimeSeriesLab(labData = imputedData,
                  idColName = ID,
                  labItemColName = ITEMID,
                  windowColName = Window,
                  valueColName = Max)

DHLab-TSENG/lab documentation built on Sept. 1, 2023, 9:03 p.m.