ellessenne / comorbidity

An R package for computing comorbidity scores.
https://ellessenne.github.io/comorbidity/
GNU General Public License v3.0
80 stars 21 forks source link

id column name if not 'id' #20

Closed axjadamson closed 4 years ago

axjadamson commented 5 years ago

Hello, I have been trying to use your comorbidity package. Thank you for creating it, it's great. I just thought I'd report an issue I found, which is that the id column must be named 'id' for the function to work. I think this should either be stated in the package or the function should be made more generalisable.

This is my first time using Github so please forgive me if I haven't formed this comment in the right way or in the right place!

Alex

Reproducible code:

x <- data.frame( id = sample(1:15, size = 200, replace = TRUE), code = sample_diag(200), stringsAsFactors = FALSE )

colnames(x) <- c("testid", "code")

comorbidity(x = x, id = "testid", code = "code", score = "charlson", assign0 = TRUE, tidy.codes = TRUE)

ellessenne commented 5 years ago

Thanks for the heads-up!

This is unexpected, and I can reproduce the error. I will look into it, thanks for reporting this bug!

ellessenne commented 5 years ago

Hi again @axjadamson, I just pushed a patch to the development version (here on GitHub), could you install it using devtools::install_github("ellessenne/comorbidity") and check if the issue is solved?

I added a couple of tests and it looks ok on my side, but it'd be great to have your feedback before closing this issue.

Thanks!

axjadamson commented 5 years ago

Hi ellessenne, Thank you very much for looking at this so quickly. I'm sorry but I haven't been able to check the new code, due to an issue with the install_github command (this one: https://stackoverflow.com/questions/57777382/cannot-install-an-r-package-from-github). However, if you think it's sorted then I trust your judgement! Alex

lauramrp commented 5 years ago

Hi Ellessenne I found the same thing for code, when I changed "diag" to "code" it worked. It was all working before I updated to the latest version of R so I don't know if it's something to do with the order I've reinstalled my packages. Thanks Laura

charls<-comorbidity(x = diag2, id = "id", code = "diag",

ellessenne commented 5 years ago

@axjadamson Sorry to hear you are having issues with devtools::install_github - if you send me an e-mail at ag475[at]le.ac.uk I can send you a pre-built version with instructions on how to install it for you to check!

@lauramrp Thanks for reporting this - I think it is the same issue that I just fixed for the ID variable, so it should be relatively straightforward to fix. I'll keep you posted!

ellessenne commented 5 years ago

Hi @axjadamson and @lauramrp, I think I fixed the second issue (with the code variable) as well. Any feedback is welcome before I go ahead and close this issue / submit an update to CRAN!

Try using the remotes package to install the dev version from GitHub:

# install.packages("remotes")
remotes::install_github("ellessenne/comorbidity")
axjadamson commented 5 years ago

Hi @ellessenne, I tried what you suggested and received this error:

'Error: Failed to install 'comorbidity' from GitHub: (converted from warning) cannot remove prior installation of package ‘backports’

I think you should go ahead with the update regardless!

ellessenne commented 5 years ago

Hi @axjadamson and @lauramrp, a new version of comorbidity is on its way to CRAN - please give it a go once it gets there!