findClosestToBaseline: Finds the measurement date that is closest to baseline

View source: R/helperFunctions.R

findClosestToBaselineR Documentation

Finds the measurement date that is closest to baseline

Description

Finds the measurement date that is closest to baseline in the given time period around baseline.

Usage

findClosestToBaseline(
  serialDf,
  baselineDates,
  blDayDiff = 90,
  idColumn = "PATIENT",
  dateColumn = "VISIT",
  dataColumn = "MEASURE"
)

Arguments

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

df

the data frame to check

dayDiff

time around baseline (default: 90 days, will look three months before and after baseline)

Value

data frame with baseline measure or NA if no measurement was close to baseline

Examples

## Not run: 
baselinePatients <- read_tsv('../data/ourBaselinePatients.txt', guess_max = 3582) %>%
    select(PATIENT, VISIT = VISIT_TL)
bmi <- read_tsv('../data/serial_bmi.txt') # contains serial and baseline data
baselinePatients <- findClosestToBaseline(bmi, baselinePatients, blDayDiff = 90)

## End(Not run)

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