简体   繁体   中英

R- too many columns when using sqldf to join dataframes

I'm trying to merge two data frames into one. The first df is acutedm11 with 4682 columns and the second is gwlfullflattened22 with 4903 columns. I can't post the data here because its too big and it contains sensitive information. I'm trying to merge these two dfs based off of mrn=mrn_G and date difference <= 30

Code:

library(sqldf)
acutedm3 <- sqldf::sqldf("
    select acutedm11.*, gwlfullflattened22.*
    from acutedm11
       left join gwlfullflattened22 on acutedm11.mrn = gwlfullflattened22.mrn_G
        and gwlfullflattened22.EncounterDate_G between acutedm11.Date_m30 and acutedm11.Date_p30") %>%
  select(-Date_m30, -Date_p30)

Error: Error: too many columns on acutedm11

Is there a better way to merge/join the data frames?

  1. The maximum number of columns is a compile time parameter in SQLite (which is included in the RSQLite package). You can reset the limit higher and rebuild that package. For more info see: Maximum number of columns in a table for sqlite

  2. Also sqldf supports 4 different back end: SQLite, H2, MySQL and PostgreSQL. Try one of the others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM