Skip to content
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

Package compatibility #60

Open
ellessenne opened this issue Aug 16, 2022 · 0 comments
Open

Package compatibility #60

ellessenne opened this issue Aug 16, 2022 · 0 comments
Assignees

Comments

@ellessenne
Copy link
Owner

Following some e-mail feedback, I think it would be good to add to the package the following functions:

  • comorbidity_check() (or some similar name) to verify if a user-supplied comorbidity dataset is compatible with the package;
  • set_comorbidity() (or similar) to add the required internal structure/attributes to yield a comorbidity-compatible object.

Example code using the current (2022-08-16) dev version:

library(comorbidity)
#> This is {comorbidity} version 1.0.3.
#> A lot has changed since the pre-1.0.0 release on CRAN, please check-out breaking changes here:
#> -> https://ellessenne.github.io/comorbidity/articles/C-changes.html
df <- data.frame(
  id = 1,
  mi = 1,
  chf = 0,
  pvd = 0,
  cevd = 0,
  dementia = 0,
  cpd = 0,
  rheumd = 0,
  pud = 0,
  mld = 0,
  diab = 0,
  diabwc = 1,
  hp = 1,
  rend = 0,
  canc = 0,
  msld = 0,
  metacanc = 0,
  aids = 0
)
score(x = df)
#> Error: This function can only be used on an object of class 'comorbidity', which you can obtain by using the 'comorbidity()' function. See ?comorbidity for more details.

class(df) <- c("comorbidity", class(df))
attr(df, "map") <- "charlson_icd10_quan"
score(x = df, assign0 = FALSE)
#> [1] 3
#> attr(,"map")
#> [1] "charlson_icd10_quan"
score(x = df, weights = "quan", assign0 = FALSE)
#> [1] 3
#> attr(,"map")
#> [1] "charlson_icd10_quan"
#> attr(,"weights")
#> [1] "quan"

df$mi <- NULL
score(x = df, assign0 = FALSE)
#> Error in `[.data.frame`(x, , names(.maps[[map]])): undefined columns selected

Created on 2022-08-16 by the reprex package (v2.0.1)

@ellessenne ellessenne self-assigned this Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant