Tuesday, September 08, 2015

How to speed up csv import in R

If you're storing a lot of data in csv files, reading it to R with read.csv can be painfully slow. Using the fread function from the data.table library increase read speed by 100x, so definitely check it out.

library(data.table)
data <- fread('data.csv')

If you prefer to work with a data.frame, it's easy to tell fread to save it as such as well.

data <- fread('data.csv', data.table=FALSE)

No comments:

Entertaining Blogs - BlogCatalog Blog Directory
Bloggtoppen.se