Description Usage Arguments Value Examples
View source: R/add_phecode_levels.R
Takes a dataframe with a phecode column and replaces it with the
hierarchichal levels of the phecodes as columns code_l1, code_l2
and
code_l3
.
1 2 3 4 5 | add_phecode_levels(
phecode_data,
phecode_column = phecode,
remove_phecode_column = TRUE
)
|
phecode_data |
Dataframe with a column encoding phecodes (make sure
codes are normalized via |
phecode_column |
Unquoted name of the column containing phecodes |
remove_phecode_column |
Should the original phecode column be kept in the data? |
Dataframe with phecode levels added as three integer columns
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | patient_data <- dplyr::tribble(
~patient, ~code, ~counts,
1, "250.23", 7,
1, "250.25", 4,
1, "696.42", 1,
1, "555.21", 4,
2, "401.22", 6,
2, "204.21", 5,
2, "735.22", 4,
2, "751.11", 2,
)
# Default removes original phecode column
add_phecode_levels(patient_data, code)
# Can keep original column as well
add_phecode_levels(patient_data, code, remove_phecode_column = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.