[R] loop, pipe connection, output objects

Marco Grazzi marco.grazzi at sssup.it
Fri Oct 13 16:05:02 CEST 2006


Hi all,

I have the following -newbye- problem.
Inside R, I am trying to process a file and creating from it many files.
The file is organized in different columns, the second containing a code. I want to create as output objects, which contain only entries in a certain code range, and whose name contain the code itself.
Here is my attempt

indice <- (201:399)
for(i in indice){
  data.i <-  read.table(pipe(paste("gawk '{if ($2 >=", i," && $2<", i+1,") print $2,$3}' < base_6_mod "  , sep='')))
    print(paste("code ...", i, "  ... done"))
}

The problems are:
1- My sintax "data.i" does not work, and loop only produces a big "data.i" object. My goal, obviously was to have something like data.201, data.202, etc
(second order problem)
2- I wonder if the sintax for the index ($2 >=", i," && $2<", i+1,") works

Thanks for your help (hoping I manged to be enough clear), 
marco
-- 

Marco Grazzi



More information about the R-help mailing list