-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow custom list of codes #35
Comments
Some of the code that @fiksdala has written in his fork already does something like this. He uses it to automatically parse the SAS code from AHRQ's latest Elixhauser algorithm and turn it into regex patterns that can be used when updating the R code of his fork. |
Yep - I already have an idea on how to implement it, with the main goal to provide a "custom" score option to the end user. |
I came across this package when I was researching ways to calculate comorbidity indices. Am I correct in understanding that this is the issue for allowing comorbidity() to work on multiple columns? The HCUP databases have ~40 columns of ICD10 codes, and I can't find a way to pass them through. If so, how is this part of the project coming along? Do you need some help with it? I am developing my own R package for working with HCUP databases, and I'd love to be able to use your package for calculating Elxihauser scores. |
Hi! library(comorbidity)
library(tidyr)
set.seed(1)
N <- 15
x <- data.frame(
id = seq(N),
code1 = sample_diag(N),
code2 = sample_diag(N),
code3 = sample_diag(N),
code4 = sample_diag(N),
code5 = sample_diag(N),
code6 = sample_diag(N),
code7 = sample_diag(N),
code8 = sample_diag(N),
code9 = sample_diag(N),
code10 = sample_diag(N)
)
head(x)
#> id code1 code2 code3 code4 code5 code6 code7 code8 code9 code10
#> 1 1 C260 T408 F458 N013 J100 V46 P509 Y606 A422 C694
#> 2 2 S10 C005 D181 S398 T940 B901 B217 K10 S564 K02
#> 3 3 L572 T132 Q691 N823 S497 P788 Q113 N130 B210 S770
#> 4 4 X46 R853 L200 N850 D838 T788 Q978 N481 H118 A921
#> 5 5 V470 N926 P121 O747 H051 A665 Q984 S907 T622 P23
#> 6 6 Y449 P130 K45 M964 Y402 B582 I749 N951 P298 B942
xlong <- pivot_longer(x, cols = starts_with("code"))
head(xlong)
#> # A tibble: 6 x 3
#> id name value
#> <int> <chr> <chr>
#> 1 1 code1 C260
#> 2 1 code2 T408
#> 3 1 code3 F458
#> 4 1 code4 N013
#> 5 1 code5 J100
#> 6 1 code6 V46
comorbidity(x = xlong, id = "id", code = "value", score = "charlson", assign0 = FALSE)
#> id ami chf pvd cevd dementia copd rheumd pud mld diab diabwc hp rend canc
#> 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
#> 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 1
#> 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 7 7 0 0 0 0 0 1 0 0 1 0 0 0 0 1
#> 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 9 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 10 10 0 0 0 0 1 0 0 0 0 0 0 0 0 1
#> 11 11 0 0 0 0 0 0 0 0 0 0 0 0 0 1
#> 12 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> 13 13 0 0 0 0 0 1 0 0 0 0 0 0 0 1
#> 14 14 0 0 0 0 0 0 0 0 0 1 0 0 0 1
#> 15 15 0 0 0 0 0 0 0 0 0 0 0 0 0 1
#> msld metacanc aids score index wscore windex
#> 1 0 0 0 1 1-2 2 1-2
#> 2 0 0 1 2 1-2 8 >=5
#> 3 0 0 1 1 1-2 6 >=5
#> 4 0 0 0 0 0 0 0
#> 5 0 0 0 0 0 0 0
#> 6 0 0 0 0 0 0 0
#> 7 0 0 0 3 3-4 4 3-4
#> 8 0 0 0 0 0 0 0
#> 9 0 0 0 0 0 0 0
#> 10 0 0 0 2 1-2 3 3-4
#> 11 1 0 0 2 1-2 5 >=5
#> 12 0 0 0 0 0 0 0
#> 13 0 0 0 2 1-2 3 3-4
#> 14 0 0 1 3 3-4 9 >=5
#> 15 0 0 0 1 1-2 2 1-2 Created on 2021-04-16 by the reprex package (v2.0.0) |
The idea is to allow the user passing a list of codes, e.g. a different comorbidity map.
Could use something like this to turn a list of codes into a regex:
Created on 2021-01-14 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: