[R] How to specify ff object filepaths when reading a CSV file into a ff data frame.

Xiaobo Gu guxiaobo1982 at gmail.com
Sun Dec 26 04:56:24 CET 2010


Hi, I have done another simple test, I test the two syntext against a
CSV file with only one column, both success,

> fdf <- read.csv.ffdf(file="D:/rtemp/fftest2.csv",asffdf_args = list( col_args =  list(filename=c("F:/a.f"))))
> fdf
ffdf (all open) dim=c(2,1), dimorder=c(1,2) row.names=NULL
ffdf virtual mapping
     PhysicalName VirtualVmode PhysicalVmode  AsIs VirtualIsMatrix
PhysicalIsMatrix PhysicalElementNo PhysicalFirstCol PhysicalLastCol
PhysicalIsOpen
col1         col1      integer       integer FALSE           FALSE
       FALSE                 1                1               1
   TRUE
ffdf data
  col1
1    1
2    2


> fdf <- read.csv.ffdf(file="D:/rtemp/fftest2.csv",asffdf_args = list( col_args =  c(list(filename="D:/a2.f"))))
> fdf
ffdf (all open) dim=c(2,1), dimorder=c(1,2) row.names=NULL
ffdf virtual mapping
     PhysicalName VirtualVmode PhysicalVmode  AsIs VirtualIsMatrix
PhysicalIsMatrix PhysicalElementNo PhysicalFirstCol PhysicalLastCol
PhysicalIsOpen
col1         col1      integer       integer FALSE           FALSE
       FALSE                 1                1               1
   TRUE
ffdf data
  col1
1    1
2    2
>

Regards,

Xiaobo Gu



On Fri, Dec 24, 2010 at 11:27 PM, Xiaobo Gu <guxiaobo1982 at gmail.com> wrote:
> Hi,
>    The read.csv.ffdf function in package ff will create the ff object
> physical file in the default directories, I am trying to let the files
> created in the paths users specify, I think the point is to make use
> of the asffdf_args parameter,
> I have a test CSV file named D:\rtemp\fftest.csv, the content of the
> file is as following:
>
> col1,col2,col3
> 1,"amber",2.4
> 2,"linda",4.5
>
> I tried the following code, hoping ff will create the physical files
> for col1,col2 and col3 to D:/a.f,D:/b.f,D:/c.f respectively
>
>  fdf <- read.csv.ffdf(file="D:/rtemp/fftest.csv",asffdf_args = list(
> col_args =  c(list(filename="D:/a.f"), list(filename="D:/b.f"),
> list(filename="D:/c.f"))))
> and the error message is :
> Error in as.ff.default(1:2, vmode = NULL, filename = "D:/a.f",
> filename = "D:/b.f",  :
>  formal argument "filename" matched by multiple actual arguments
>
> I also tried the following:
>
>> fdf <- read.csv.ffdf(file="D:/rtemp/fftest.csv",asffdf_args = list( col_args =  list(filename=c("D:/a.f","D:/b.f","D:/c.f"))))
> Error in ff(initdata = initdata, length = length, levels = levels,
> ordered = ordered,  :
>  bad argument initdata for existing file; initializing existing file is invalid
> In addition: Warning messages:
> 1: In if (file.exists(filename)) { :
>  the condition has length > 1 and only the first element will be used
> 2: In if (file.exists(filename)) { :
>  the condition has length > 1 and only the first element will be used
> 3: In if (file.access(filename, 4) == -1) { :
>  the condition has length > 1 and only the first element will be used
> 4: In if (file.access(filename, 2) == -1) { :
>  the condition has length > 1 and only the first element will be used
> 5: In if (is.na(filesize)) stop("unable to open file") :
>  the condition has length > 1 and only the first element will be used
>
> My questions are:
> 1. What's the datatype of the col_args parameter of the as.ffdf function
> 2. If I can make layout of the asffdf_args parameter correct, how can
> I set the exact filenames for each column of the ff data frame.
>
> Regards,
>
> Xiaobo Gu
>



More information about the R-help mailing list