darwin-eu-dev / PatientProfiles

https://darwin-eu-dev.github.io/PatientProfiles/
Apache License 2.0
6 stars 5 forks source link

addCategories for dates not working as expected #670

Closed daniellenewby closed 2 months ago

daniellenewby commented 2 months ago

I am trying to obtain categories of patients based on year of diagnosis (cohort_start_date) using addCategories. I have created the following code:

cdm$outcome <- cdm$outcome %>% 
  PatientProfiles::addCategories(
    variable = "cohort_start_date",
    categories = list("diag_yr_gp" = list(
      "2003 to 2006" = as.Date(c("2003-01-01", "2006-12-31")),
      "2007 to 2010" = as.Date(c("2007-01-01", "2010-12-31")),
      "2011 to 2014" = as.Date(c("2011-01-01", "2014-12-31")),
      "2015 to 2018" = as.Date(c("2015-01-01", "2018-12-31")),
      "2019 to 2022" = as.Date(c("2019-01-01", "2022-12-31"))
    )
    )
  )

What i would expect is categories of for example "2003-2006" however i get 2003-01-01 to 2003-01-01. So its the right category but the label is not correct.

image

catalamarti commented 2 months ago

This should be easy to fix, the categories argument is ignoring the names. @ilovemane do you want to take a look?