map_to_universal_session_id: Change idiosyncratic session ID codes to a consistent...

View source: R/clean_data.R

map_to_universal_session_idR Documentation

Change idiosyncratic session ID codes to a consistent canonical form

Description

map_to_universal_session_id Add a column of a canonical session ID to a given dataframe, created by matching the session label from the dataframe (which tends to be ad hoc and error prone) via a lookup table. That table maps the many different session IDs used across various data sources to a single canonical one that can be used to link records more reliably. For example, given a session code like 999BIO_F19, return a code like 999BIO_2018-12-25. This allows matching across data sources that could be using different labels for the same actual session. The date is a single date that describes all the associated visits that are linked to that session, even if they occurred some days or weeks apart.

Usage

map_to_universal_session_id(
  dataset,
  make_session_label = TRUE,
  remove_double_measures = TRUE,
  drop_original_columns = TRUE
)

Arguments

dataset

A dataframe containing a session ID column that needs to be made consistent.

make_session_label

For most dataframes we need to concatenate the subject ID and a session suffix to form a session label. This can be suppressed for sources like the Alice exported session data that already contain a unitary session label.

remove_double_measures

Some measures might occur twice within an overarching session (e.g. meds or UPDRS have occasionally been assessed several times, separated by just days or weeks). Generally, we remove all but the latest value from a session.

drop_original_columns

There is usually no need to retain the original idiosyncratic session columns once the new unified one has been provided.

Value

The dataframe originally passed in to the function but with the session IDs replaced with canonical ones.

Examples

## Not run: 
some_data <- map_to_universal_session_id(some_data)

## End(Not run)

nzbri/chchpd documentation built on July 6, 2023, 11:27 p.m.