combine_current_and_past_observations: Combine Current and Past Observations

View source: R/combine_current_and_past_observations.R

combine_current_and_past_observationsR Documentation

Combine Current and Past Observations

Description

This is a specialized function for use with LAVA Query data frames, and can be thought of as a conditional version of spread() or pivot_longer(). There are a number of questionnaires where data is collected about the "current" time point and about a time in the "past," generally 5 years in the past for the questionnaires we use. This "past" data is collected only once while the "current" data is collected at initial and every subsequent visit. Ultimately, researchers will want to calculate change scores from before someone's diagnosis, and this function places the "past/before" data next to every instance of "current" data/

Usage

combine_current_and_past_observations(
  .data,
  CurrentPast = CurrentPast,
  DCDate = DCDate,
  PIDN = PIDN
)

Arguments

.data

A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).

CurrentPast

variable indicating whether the observation is a "Current" or "Past" record; default column name expected is CurrentPast, but can be replaced with any column with "current" and "past"/"before" characters

DCDate

date column; defaults to DCDate

PIDN

identifier column; defaults to PIDN

Value

dataframe


NeuroShepherd/RankinLabTools documentation built on Sept. 23, 2022, 5:31 p.m.