Rdatatable / data.table

R's data.table package extends data.frame:
http://r-datatable.com
Mozilla Public License 2.0
3.61k stars 984 forks source link

Error related to merging on character vs factor column #5391

Closed iMissile closed 3 months ago

iMissile commented 2 years ago

Hello. I've tested data.table dev version 1.14.3 as it has so many features and bugfixes. Unfortunately package bupaverse/processmapR) become broken due some changes in data.table internal logic. I suppose current issue can be a clarification of https://github.com/Rdatatable/data.table/issues/5361 as it influence @ work of another packages, not my personal code.

Error can be reproduced enven in public bupaR sample:

library(bupaR)
patients %>%
    process_map()
#> Error in rbindlist(l, use.names, fill, idcol) : 
#>   Class attribute on column 7 of item 2 does not match with column 7 of item 1.

More precisely, I tried to debug and found that error raised at this line https://github.com/bupaverse/processmapR/blob/6dbf8d776204b6706432f2fdf81b22a1ab6dcaae/R/process_map.R#L198 during data.table::merge by ordered factor and character.

When I rollback data.table to version 1.14.2 everything returns to working state.

SessionInfo()

R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] petrinetR_0.2.1     processmonitR_0.1.0 xesreadR_0.2.3      processmapR_0.3.4   eventdataR_0.3.0   
 [6] edeaR_0.8.6         bupaR_0.4.4         fstcore_0.9.12      lgr_0.4.3           tsibble_1.1.1      
[11] furrr_0.3.0         future_1.25.0       dqrng_0.3.0         rTRNG_4.23.1-2      anytime_0.3.9      
[16] stringi_1.7.6       data.table_1.14.3   tictoc_1.0.1        datapasta_3.1.0     magrittr_2.0.3     
[21] forcats_0.5.1       stringr_1.4.0       dplyr_1.0.9         purrr_0.3.4         readr_2.1.2        
[26] tidyr_1.2.0         tibble_3.1.7        ggplot2_3.3.6       tidyverse_1.3.1    
jangorecki commented 10 months ago

Could we have a minimal example code to reproduce?