# NOT RUN {
library(icd)
# magrittr not required for icd to work, just for this example
library(magrittr, warn.conflicts = FALSE, quietly = TRUE)
myData <- data.frame(
visit_id = c("v1", "v2", "v3", "v4"),
diag = c("39891", "39790", "41791", "4401"),
poa = c("Y", "N", NA, "Y"),
stringsAsFactors = FALSE
)
myData %>%
filter_poa_not_no() %>%
comorbid_ahrq()
# can fill out named fields also:
myData %>%
filter_poa_yes(poa_name = "poa") %>%
comorbid_ahrq(
icd_name = "diag", visit_name = "visit_id",
short_code = TRUE
)
my_map <- head(icd9_map_elix)
# can call the core comorbid() function with an arbitrary mapping
myData %>%
filter_poa_yes() %>%
comorbid(
icd_name = "diag",
visit_name = "visit_id",
map = my_map,
short_map = TRUE
)
# }
Run the code above in your browser using DataLab