View source: R/clinical_events.R
mutate_age_at_event_cols | R Documentation |
Mutates numeric columns with the age at event (in years) for all columns that match the
regex supplied to date_col_regex
.
mutate_age_at_event_cols(
ukb_main,
dob_col = "dob",
date_col_regex = "_date$",
date_col_regex_replacement = "_age"
)
ukb_main |
a UKB main dataset (data frame) containing a column named
"eid" and a date of birth column, as well as date columns matching the
regex supplied to the |
dob_col |
character. The name of the date of birth column in
|
date_col_regex |
character. A regular expression that matches the date
columns to be processed in |
date_col_regex_replacement |
character. New "age-at-event" columns will
have names matching those of the input date columns, replacing the regex
supplied to |
A data frame with additional "age at event" columns (in years).
# dummy data
dummy_ukb_main <- tibble::tribble(
~eid, ~dob, ~event_date,
1, "2000-01-01", "2010-01-01"
)
# mutate age at event col
mutate_age_at_event_cols(
dummy_ukb_main,
dob_col = "dob",
date_col_regex = "_date$",
date_col_regex_replacement = "_age"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.