目前的方法太多了,无法逐一粘贴每个列表。
# CURRENT METHOD
FL_PATH_1 <- list.files(path = "~/MY_FOLDER_1"),
pattern = "*.CSV",full.name = T)
FL_PATH_2 <- list.files(path = "~/MY_FOLDER_2"),
pattern = "*.CSV",full.name = T)
FL_PATH_3 <- list.files(path = "~/MY_FOLDER_3"),
pattern = "*.CSV",full.name = T)
FL_PATH_BP_A <- append(FL_PATH_1 ,FL_PATH_2)
FL_PATH_BP_A_2 <- append(FL_PATH_BP_A,FL_PATH_3)
DT <- rbindlist(lapply(FL_PATH_BP_A_2 ,import,header=T,sep=",",
setclass = "data.table"))
有没有有效而灵活的方法来解决这个案例? *每个列表都必须是list.files(),因为它们正在获取某些文件夹中的所有文件
folders <- c("folder1","folder2","folder3")
files <- c()
for (folder in folders) {
files <- c(list.files(folder, pattern = "*.CSV",full.name = T)))
}