Create a data frame with cases and matched controls
Source:R/case_control_match.R
create_case_control_matched_df.Rd
Create a data frame with cases and matched controls
Usage
create_case_control_matched_df(
df,
case_control_colname,
case_value = "Case",
control_value = "Control",
matching_vars_categorical = NULL,
matching_vars_continuous = NULL,
n_control_ratio = 4,
seed = 42
)
Arguments
- df
A data frame
- case_control_colname
Character. The name of an indicator column in
df
that labels individuals as either cases or controls.- case_value
String Used to determine which individuals are cases. This value should be present in
df[[case_control_colname]]
.- control_value
String Used to determine which individuals are controls This value should be present in
df[[case_control_colname]]
.- matching_vars_categorical
Character vector of column names containing categorical variables to match on. These columns should all be of type character.
- matching_vars_continuous
Named integer vector. Names should be column names containing continuous variables to match on (these columns should all be of type numeric). Integer values are the number of digits to match to. For example,
c("age_yrs" = 0)
specifies that controls will be matched on 'age_yrs' to the nearest year.- n_control_ratio
Integer. The number of controls to match for each case.
- seed
Integer, for reproducibility.