Describes a single variable to extract from the CDM. Variables reference
a source table and column, and may include concept-level filtering and
output formatting options. Variables are the atomic building blocks passed to
omop_recipe via its variables argument (or grouped with
omop_variable_block and passed via blocks).
Usage
omop_variable(
name = NULL,
table,
column = NULL,
concept_id = NULL,
concept_name = NULL,
type = c("auto", "numeric", "categorical", "date", "boolean", "integer", "character"),
format = c("raw", "binary", "count", "first_value", "last_value", "mean", "min", "max",
"time_since", "binned", "age", "sex_mf", "obs_duration", "drug_duration", "sum",
"n_distinct", "sd", "cv", "slope", "abnormal_high", "abnormal_low", "gap_max",
"gap_mean", "duration_sum", "prior_obs", "followup", "demo_missingness", "charlson",
"chads2", "chadsvasc", "dcsi", "hfrs"),
value_source = NULL,
time_window = NULL,
suffix_mode = c("index", "range", "label"),
filters = list(),
visit_filter = NULL,
concept_col = NULL,
expand = FALSE,
reference_date = NULL,
unit = NULL
)Arguments
- name
Character; output column name (auto-generated from
concept_name,concept_id, orcolumnifNULL).- table
Character; source OMOP CDM table (e.g.
"condition_occurrence").- column
Character or
NULL; source column to extract.- concept_id
Integer or
NULL; concept ID filter (for concept columns).- concept_name
Character or
NULL; human-readable concept name.- type
Character; variable type hint. One of
"auto","numeric","categorical","date","boolean","integer","character".- format
Character; output format. One of
"raw","binary","count","first_value","last_value","mean","min","max", and"time_since", plus the documented derived and longitudinal summary formats."time_since"requires a fixedreference_date; cohort-index recency remains episode-specific and is rejected. Calendar binning is configured withomop.date_handling, not as a variable format.- value_source
Character or
NULL; column to extract value from (e.g."value_as_number"for measurements).- time_window
Named list with
start/endoffsets relative to index date, orNULLfor no window constraint.- suffix_mode
Character; how to name multi-column expansions (
"index","range", or"label").- filters
List of
omop_filterobjects to apply to this variable.- visit_filter
Named list
list(concept_ids = ...)orNULL; restrict this variable's events to visits of thosevisit_concept_idvalues (via thevisit_occurrence_idlink).- concept_col
Character or
NULL; override the concept column theconcept_id/concept set scopes (default: the table's domain concept), e.g."unit_concept_id"to extract a single unit for harmonization.- expand
Logical; if
TRUE, expand the concept to include vocabulary descendants server-side (defaultFALSE).- reference_date
Character/Date or
NULL; fixed ISO reference date required whenformat = "time_since".- unit
Character or
NULL;"day"(default fortime_since) or"month". Months are complete calendar months, not fixed 30-day intervals.
Examples
if (FALSE) { # \dontrun{
recipe <- omop_recipe(
variables = omop_variable(
table = "condition_occurrence",
concept_id = 201820,
concept_name = "Type 2 diabetes",
format = "binary"
),
outputs = omop_output(type = "wide")
)
} # }