Either grabs a vector of descriptions for passed vector of phecodes, or vector of categories, or a dataframe with both.
get_phecode_info(codes, what = "description")
codes | Vector of phecodes |
---|---|
what | What info should be returned. Options: |
Vector of what
is description or category, dataframe with phecode,
description, and category if what = 'all'
.
get_phecode_info
library(dplyr)#> #>#>#> #>#>#> #># Simulate some random data associated with phecodes data_w_phecodes <- sample_n(phecode_descriptions, 100) %>% select(code = phecode) %>% mutate(random = rnorm(n())) # Use function to add a column with description data_w_phecodes %>% mutate(descrip = get_phecode_info(code, 'description'))#> # A tibble: 100 x 3 #> code random descrip #> <chr> <dbl> <chr> #> 1 593.10 1.40 Gross hematuria #> 2 696.40 -0.679 Psoriasis #> 3 292.40 0.738 Altered mental status #> 4 132.00 -0.861 Infestation (lice, mites) #> 5 300.90 0.421 Posttraumatic stress disorder #> 6 340.10 1.45 Migrain with aura #> 7 480.13 0.194 MRSA pneumonia #> 8 931.00 -0.691 Contact dermatitis and other eczema due to plants [except food] #> 9 600.00 1.34 Hyperplasia of prostate #> 10 225.00 2.74 Benign neoplasm of brain and other parts of nervous system #> # … with 90 more rows# Use function to add column with category data_w_phecodes %>% mutate(category = get_phecode_info(code, 'category'))#> # A tibble: 100 x 3 #> code random category #> <chr> <dbl> <chr> #> 1 593.10 1.40 genitourinary #> 2 696.40 -0.679 dermatologic #> 3 292.40 0.738 mental disorders #> 4 132.00 -0.861 infectious diseases #> 5 300.90 0.421 mental disorders #> 6 340.10 1.45 neurological #> 7 480.13 0.194 respiratory #> 8 931.00 -0.691 dermatologic #> 9 600.00 1.34 genitourinary #> 10 225.00 2.74 neoplasms #> # … with 90 more rows# Use function to get dataframe of category and description that can be to join # with data bind_cols( data_w_phecodes, get_phecode_info(data_w_phecodes$code, 'all') )#> # A tibble: 100 x 5 #> code random phecode description category #> <chr> <dbl> <chr> <chr> <chr> #> 1 593.10 1.40 593.10 Gross hematuria genitourinary #> 2 696.40 -0.679 696.40 Psoriasis dermatologic #> 3 292.40 0.738 292.40 Altered mental status mental disord… #> 4 132.00 -0.861 132.00 Infestation (lice, mites) infectious di… #> 5 300.90 0.421 300.90 Posttraumatic stress disorder mental disord… #> 6 340.10 1.45 340.10 Migrain with aura neurological #> 7 480.13 0.194 480.13 MRSA pneumonia respiratory #> 8 931.00 -0.691 931.00 Contact dermatitis and other eczema due… dermatologic #> 9 600.00 1.34 600.00 Hyperplasia of prostate genitourinary #> 10 225.00 2.74 225.00 Benign neoplasm of brain and other part… neoplasms #> # … with 90 more rows