How to import multiple data files (the fast way)


Sometimes you have your data stored in multiple csv files and want to load them into a single data frame in R. There are several answers on the web to this questions and I recently found a fast solution to this problem.

# packages

# set wd

# import files
files = list.files(pattern="*.csv")
dataset =, lapply(files, fread))

# transform data to df
dataset <-

The code above uses both lapply and the cool fread function from the data.table package to load in your data in a quiet fast manner. I recommend to try out this approach if you dealing with long import times.

Make sure you check out my Github for other data driven projects.

Author: inside data blog

data analysis & visualization blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s