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

Only numeric as ID ???? #55

Closed norihikorihiko closed 2 years ago

norihikorihiko commented 2 years ago

I got error in ID with following message in version 1.0.2. Former version I could use alphabetical letter in ID column.

Error in data.table::setnafill(x = x, type = "const", fill = 0L) : 'x' argument must be numeric type, or list/data.table of numeric types

ellessenne commented 2 years ago

Hi, Thanks for the bug report - I can reproduce the issue with the code below:

library(comorbidity)
set.seed(1)
x <- data.frame(
  id = sample(1:15, size = 200, replace = TRUE),
  code = sample_diag(200),
  stringsAsFactors = FALSE
)
x$id <- as.character(x$id)
comorbidity(x = x, id = "id", code = "code", map = "charlson_icd10_quan", assign0 = FALSE)
#> Error in data.table::setnafill(x = x, type = "const", fill = 0L): 'x' argument must be numeric type, or list/data.table of numeric types

Created on 2022-04-27 by the reprex package (v2.0.1)

I think this is related to this, I'll look into it as soon as possible!

ellessenne commented 2 years ago

Hi again @norihikorihiko, I think I might have identified and fixed the issue. Could you give it a go by installing from GitHub with:

library(remotes)
remotes::install_github(repo = "ellessenne/comorbidity", ref = "#55")

Thanks,

Alessandro

jwallib commented 2 years ago

Hi there @ellessenne,

I am also experiencing this issue and the fix you posted has not resolved it for me. Even using the same sample code you posted above.

Best wishes,

Jamie

ellessenne commented 2 years ago

Hi @jwallib, Thanks for the feedback. Do you have a reproducible example? What type is your ID column? Thanks,

Alessandro

jwallib commented 2 years ago

Apologies @ellessenne it is working now after having restarted my R session. Thanks for the fix,

Best wishes,

Jamie

ellessenne commented 2 years ago

I see, no worries, and thanks for letting me know!

vivek-verma202 commented 2 years ago

Hi @ellessenne , I am facing the same issue, even after updating the library to v1.0.2.9000 using: remotes::install_github(repo = "ellessenne/comorbidity", ref = "#55")

Currently, my data.table looks like this: image

And the code chunk is:

 comorbidity::comorbidity(
    x = x,
    id="PatientID",
    code="DiagnosisCode",
    map="charlson_icd10_quan",
    tidy.codes = TRUE,
    assign0=FALSE)

image

Thanks a lot!

ellessenne commented 2 years ago

HI @vivek-verma202, thanks for reporting this. What is the specific error that you get? Could you provide a reproducible example?

cole-johanson commented 2 years ago

@ellessenne your fix solved this bug for me as well. Thank you!

ellessenne commented 2 years ago

No worries @cole-johanson, thanks for letting me know!

ellessenne commented 2 years ago

This patch is now on the latest CRAN version of {comorbidity}.