Takes a dataframe with a phecode column in it and desired new phecode information columns to it: description, category, category_number, and phecode_index (the relative position in ordered phenome of phecode).

join_phecode_info(
  data_w_phecode,
  phecode_column = phecode,
  cols_to_join = c("description", "category", "category_number", "phecode_index")
)

Arguments

data_w_phecode

Dataframe with a phecode column.

phecode_column

Unquoted column of passed data that contains phecodes

cols_to_join

Which columns of phecode info do you want appended to dataframe?

Value

input dataframe with three columns added to it.

See also

get_phecode_info

Examples

library(dplyr) data_w_phecode <- sample_n(phecode_descriptions, 100) %>% select(phecode) %>% mutate(random = rnorm(n())) # Default values data_w_phecode %>% join_phecode_info()
#> # A tibble: 100 x 6 #> phecode random description category category_number phecode_index #> <chr> <dbl> <chr> <chr> <int> <int> #> 1 965.10 -1.45 Opiates and related … injuries… 18 1818 #> 2 250.14 0.941 Type 1 diabetes with… endocrin… 3 239 #> 3 592.10 -0.339 Cystitis genitour… 11 1189 #> 4 368.40 -0.0756 Visual field defects sense or… 7 656 #> 5 740.11 0.0402 Osteoarthrosis, loca… musculos… 14 1587 #> 6 276.42 0.124 Alkalosis endocrin… 3 356 #> 7 480.30 -0.998 Pneumonia due to fun… respirat… 9 929 #> 8 966.00 1.23 Poisoning by anticon… injuries… 18 1821 #> 9 531.10 0.340 Hemorrhage from gast… digestive 10 1049 #> 10 250.12 -0.473 Type 1 diabetes with… endocrin… 3 237 #> # … with 90 more rows
# Can change name of phecode column data_w_phecode %>% rename(jd_code = phecode) %>% join_phecode_info(jd_code)
#> # A tibble: 100 x 6 #> jd_code random description category category_number phecode_index #> <chr> <dbl> <chr> <chr> <int> <int> #> 1 965.10 -1.45 Opiates and related … injuries… 18 1818 #> 2 250.14 0.941 Type 1 diabetes with… endocrin… 3 239 #> 3 592.10 -0.339 Cystitis genitour… 11 1189 #> 4 368.40 -0.0756 Visual field defects sense or… 7 656 #> 5 740.11 0.0402 Osteoarthrosis, loca… musculos… 14 1587 #> 6 276.42 0.124 Alkalosis endocrin… 3 356 #> 7 480.30 -0.998 Pneumonia due to fun… respirat… 9 929 #> 8 966.00 1.23 Poisoning by anticon… injuries… 18 1821 #> 9 531.10 0.340 Hemorrhage from gast… digestive 10 1049 #> 10 250.12 -0.473 Type 1 diabetes with… endocrin… 3 237 #> # … with 90 more rows
# Can choose which columns are added data_w_phecode %>% join_phecode_info(cols_to_join = c("description", "phecode_index"))
#> # A tibble: 100 x 4 #> phecode random description phecode_index #> <chr> <dbl> <chr> <int> #> 1 965.10 -1.45 Opiates and related narcotics causing adverse … 1818 #> 2 250.14 0.941 Type 1 diabetes with neurological manifestatio… 239 #> 3 592.10 -0.339 Cystitis 1189 #> 4 368.40 -0.0756 Visual field defects 656 #> 5 740.11 0.0402 Osteoarthrosis, localized, primary 1587 #> 6 276.42 0.124 Alkalosis 356 #> 7 480.30 -0.998 Pneumonia due to fungus (mycoses) 929 #> 8 966.00 1.23 Poisoning by anticonvulsants and anti-Parkinso… 1821 #> 9 531.10 0.340 Hemorrhage from gastrointestinal ulcer 1049 #> 10 250.12 -0.473 Type 1 diabetes with renal manifestations 237 #> # … with 90 more rows