everyone.
What I'm trying to do
To create an empty ff data.frame in R.
Details
I'd like to read multiple csv files in R, bind them together and create one big data.frame. Since the data are very huge, I'm using ff package.
Here is my code.
file_list = list.files(pattern="*.csv")
library(ff)
for(i in seq_along(length(file_list)){
ffdf <- read.csv.ffdf(x=ffdf, file=file_list[i], header=T)
}
However, I got the following error.
Error in `rownames<-`(x, value) :
attempt to set 'rownames' on an object with no dimensions
I searched the error message in Google and Stackoverflow but got no useful result. Does anyone know how to deal with this issue?
Updated (15/2/16)
The following code worked.
library(ffbase)
library(ff)
file_list = list.files(pattern="*.csv")
lst <- lapply(file_list, function(x) read.csv.ffdf(file=x,header=TRUE))
ff1 <- Reduce(function(x,y) ffdfappend(x,y, adjustvmode=F), lst)
At first, the lappy row was like this, which didn't work.
lst <- lapply(file_list, read.csv.ffdf, header=TRUE)
The key was writing file=
. It seems like ff
function requires indicating attributes explicitly.
(Reference : Import text file using ff package)
Thanks to all of you!
My environment
- Windows 7 Home Premium Service Pack 1
- R studio 0.98.1091
- R version 3.1.2 (2014-10-31)