Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.8k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...