createTimeBlocks: Calculates the time block data

View source: R/createTimeBlocks.R

createTimeBlocksR Documentation

Calculates the time block data

Description

Calculates the time block data

Usage

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
)

Arguments

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)

Value

time block data and dates in wide format

Examples

## 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)

smm52/timeBlocks documentation built on Nov. 27, 2022, 3:54 a.m.