Skip to contents

Strictly left-join phenotype, anchor, and covariate tables to a declared sample spine. Every input must contain one unique, nonmissing ID per row. Non-ID column collisions are errors, and the input objects are never modified by reference.

Usage

assemble_phewas_data(
  sample,
  phenotypes = NULL,
  anchors = NULL,
  covariates = NULL,
  id
)

Arguments

sample

Data frame defining the people and row order in the analysis.

phenotypes

Optional data frame of analysis-ready phenotypes.

anchors

Optional data frame of fixed predictors or outcomes.

covariates

Optional data frame of adjustment variables.

id

Name of the ID column shared by every supplied table.

Value

A data.table in sample-spine order. Its join_report attribute reports matches and unmatched rows for every input table.

Details

Input data tables are copied before any work is done, so this function never changes caller-owned objects by reference. Use data.table::copy() before subsequently modifying the returned table with :=, or as.data.frame() when base-data-frame semantics are preferred.