How to bind data.table without increasing the memory consumption?

后端 未结 3 493
广开言路
广开言路 2020-12-21 08:28

I have few huge datatable dt_1, dt_2, ..., dt_N with same cols. I want to bind them together into a single datatable. If I use

dt          


        
3条回答
  •  春和景丽
    2020-12-21 09:05

    I guess <<- and get can help you with this.

    UPDATE: <<- is not necessary.

    df1 <- data.frame(x1=1:4, x2=letters[1:4], stringsAsFactors=FALSE)
    df2 <- df1
    df3 <- df1
    
    dt.lst <- c("df2", "df3")
    
    for (i in dt.lst) {
      df1 <- rbind(df1, get(i))
      rm(list=i)
    }
    
    df1
    

提交回复
热议问题