Fast reading and combining several files using data.table (with fread)
问题 I have several different txt files with the same structure. Now I want to read them into R using fread, and then union them into a bigger dataset. ## First put all file names into a list library(data.table) all.files <- list.files(path = "C:/Users",pattern = ".txt") ## Read data using fread readdata <- function(fn){ dt_temp <- fread(fn, sep=",") keycols <- c("ID", "date") setkeyv(dt_temp,keycols) # Notice there's a "v" after setkey with multiple keys return(dt_temp) } # then using mylist <-