View source: R/createTimeBlocks.R
createTimeBlocks | R Documentation |
Calculates the time block data
createTimeBlocks( serialDf, baselineInfo, studyStartDate, studyEndDate, blockDays = 365.25, interpolate = TRUE, measureIsFactor = FALSE, blockSummaryStats = "median", blDayDiff = 90, idColumn = "PATIENT", dateColumn = "VISIT", dataColumn = "MEASURE", dataName = "measure", longFormat = TRUE )
serialDf |
the data frame with the serial data |
baselineInfo |
dataframe with ID and baseline date |
studyStartDate |
start Date of the study (has to be of class Date) |
studyEndDate |
end Date of the study (has to be of class Date) |
blockDays |
length of a time block in days (default 365.25 days) |
interpolate |
shall data for empty blocks be interpolated (default TRUE) |
measureIsFactor |
when FALSE (default) data will be interpolated linearly, otherwise, empty blocks will take the value of the last preceding non-empty block |
blockSummaryStats |
how to summarise the data in each block. Currently available: min, max, median, IQR |
blDayDiff |
time in days that should be searched for a measurement around the baseline visit (default 90) |
idColumn |
name of ID column: default is PATIENT |
dateColumn |
name of date column: default is VISIT. This column has to be of class Date |
dataColumn |
name of the data column: default is MEASURE |
dataName |
set a user specified name for the data column in the output: default is measure |
longFormat |
flag to indicate whether results should be in long or wide format. Wide has some additional columns (default: TRUE) |
time block data and dates in wide format
## Not run: baselinePatients <- read_tsv('../data/ourBaselinePatients.txt', guess_max = 3582) %>% select(PATIENT, VISIT = VISIT_TL) bmi <- read_tsv('../data/serial_bmi.txt') resBmiWide <- createTimeBlocks(bmi, baselinePatients, studyStartDate = as.Date('1995-01-01', '%Y-%m-%d'), studyEndDate = as.Date('2015-12-31', '%Y-%m-%d'), blDayDiff = 90, dataName = "bmi", longFormat = FALSE) resBmiTRUE <- createTimeBlocks(bmi, baselinePatients, studyStartDate = as.Date('1995-01-01', '%Y-%m-%d'), studyEndDate = as.Date('2015-12-31', '%Y-%m-%d'), blDayDiff = 90, dataName = "bmi", longFormat = TRUE) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.