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

antimicrobials atc_code index incompatible types #7

Open
Youguang opened this issue Feb 28, 2024 · 1 comment
Open

antimicrobials atc_code index incompatible types #7

Youguang opened this issue Feb 28, 2024 · 1 comment

Comments

@Youguang
Copy link

Error:

Error in left_join():
! Can't join x$atc_code with y$atc_code due to incompatible types.
x$atc_code is a .
y$atc_code is a .

Possible reason:

radar/global.R

Lines 105 to 113 in df1df23

antimicrobials <- antimicrobials %>%
mutate(ab_days = as.integer(ab_stop_date - ab_start_date),
ab_timing = as.integer(ab_start_date - adm_start_date),
ddd_per_prescription = ddd_per_day*ab_days) %>%
left_join(
AMR::antibiotics %>%
select(
atc_code = atc, ab_type = name, ab_group = atc_group2
), by = "atc_code") %>%

typeof(AMR::antibiotics$atc)
[1] "list"
@Youguang
Copy link
Author

After unnest AMR::antibiotics, it works now

antimicrobials <- antimicrobials %>% 
   mutate(ab_days = as.integer(ab_stop_date - ab_start_date), 
          ab_timing = as.integer(ab_start_date - adm_start_date), 
          ddd_per_prescription = ddd_per_day*ab_days) %>% 
   left_join( 
     AMR::antibiotics %>% 
       select( 
         atc_code = atc, ab_type = name, ab_group = atc_group2 
       ) %>% unnest(atc_code), by = "atc_code") %>% 

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

No branches or pull requests

1 participant