Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error when calling categorize() with codify_args #157

Open
mbg-unsw opened this issue Nov 11, 2024 · 1 comment
Open

Error when calling categorize() with codify_args #157

mbg-unsw opened this issue Nov 11, 2024 · 1 comment

Comments

@mbg-unsw
Copy link

A simple example based on README/Usage fails with an error I can't decipher. Am I doing something silly?

> library(coder)
Warning message:
package ‘coder’ was built under R version 4.3.3 
> m <- data.frame(UID=c("0000"), SUPP_DATE=as.Date("2024-01-01"), ATC_CODE=c("C09CA07"))
> cc <- data.frame(UID=c("0000"), SUPP_DATE=as.Date("2024-01-02"))
> ch <- categorize(cc, codedata=m, cc="rxriskv", id="UID", code="ATC_CODE",
+ codify_args = list(date="SUPP_DATE", code_date="SUPP_DATE", days=c(-365, -1)))
Classification based on: atc_pratt
Error in `[.data.frame`(y, , c(id, setdiff(names(y), id))) : 
  undefined columns selected

> sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
[...]
[1] coder_0.13.10

loaded via a namespace (and not attached):
 [1] compiler_4.3.2    magrittr_2.0.3    cli_3.6.2         generics_0.1.3   
 [5] tools_4.3.2       pillar_1.9.0      glue_1.7.0        decoder_1.2.2    
 [9] tibble_3.2.1      utf8_1.2.4        fansi_1.0.6       vctrs_0.6.5      
[13] data.table_1.15.0 lifecycle_1.0.4   pkgconfig_2.0.3   rlang_1.1.3   
@mbg-unsw
Copy link
Author

OK, this works, so it appears that the date and supp_date variables must have different names:

> library(coder)
Warning message:
package ‘coder’ was built under R version 4.3.3 
> m <- data.frame(UID=c("0000"), SUPP_DATE=as.Date("2024-01-01"), ATC_CODE=c("C09CA07"))
> cc <- data.frame(UID=c("0000"), S_DATE=as.Date("2024-01-02"))
> ch <- categorize(cc, codedata=m, cc="rxriskv", id="UID", code="ATC_CODE",
+ codify_args = list(date="S_DATE", code_date="SUPP_DATE", days=c(-365, -1)))

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant