imputeKNN | R Documentation |
imputeKNN
uses k-nearest neighbors (kNN) method to fill missing values.
imputeKNN(labData, idColName, k)
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. |
k |
the numbers of selected nearestZneighbors. |
Given wide format data, data can conduct KNN imputation. If lab item code are composed by multiple columns, it will automatically combined as one. All other columns will all be seen as value columns.
A new, wide-formatted imputed data.table
.
timeSeriesData <- getTimeSeriesLab(labData = labSample,
idColName = SUBJECT_ID,
labItemColName = ITEMID,
dateColName = CHARTTIME,
valueColName = VALUENUM,
indexDate = first,
gapDate = 360,
completeWindows = TRUE)
wideData <- wideTimeSeriesLab(labData = timeSeriesData,
idColName = ID,
labItemColName = ITEMID,
windowColName = Window,
valueColName = Max)
imputeKNN(labData = wideData,
idColName = ID + Window,
k = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.