Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.7k views
in Technique[技术] by (71.8m points)

automation - Automate data import in R

I have a folder containing 150 separate data files (saved as .dat files) and I want to import all of them into R so that I can bind them together into 1 master data file. They are all structured the same (same number and order of variables, etc), so that shouldn't be an issue. Is there a way to automate importing them all such that one piece of code will import all 150 data files in one continuous process? And once I do that, is there a way to automate binding them all together so that I don't have to write 150 separate lines of rbind? If so, that will save me a ton of time/work that I don't have to spend doing this all one at a time. Thanks in advance!

EDIT: I solved my own problem using a few other stack overflow posts. In case anyone has a similar problem, the following worked for me:

library(data.table)

setwd("WorkingDirectory")

FileList <- list.files(pattern = "*.dat") dataset <- do.call(rbind, lapply(FileList, fread)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...