[R] Output to sequentially numbered files... also, ideas for running R on Xgrid

Mario Valle mvalle at cscs.ch
Wed Mar 3 06:20:38 CET 2010


write.csv(x, file=sprintf("prefix%05d.csv", n))


On 02-Mar-10 23:26, JWC wrote:
>
> Hello,
>
> I have some code to run on an XGrid cluster.  Currently the code is written
> as a single, large job... this is no good for trying to run in parallel.  To
> break it up I have basically taken out the highest level for-loop and am
> planning on batch-running many jobs, each one representing an instance of
> the removed loop.
>
> However, when it comes to output I am stuck.  Previously the output was an
> array of [x, y, i] dimensions.  The removed for-loop ran through i, each
> iteration filling a x-y slice of the output array.  Now the function returns
> a single xy matrix for a supplied, single value of i.
>
> Is there a way to output to sequentially numbered csv files such that they
> can be reconstituted into the [x, y, i] array?
>
> I have tried:
>
> write(x, file=get("n"))
>
> Where n is the value of i the function is running for.
>
> But I get the error:
>
> 'file' must be a character string or connection
>
> Is there a way of writing out to a csv file numbered with the value of a
> variable?
>
> Also, is this a very complicated way of parallelising this function?
>
> Many thanks,
>
> Joe
>
>

-- 
Ing. Mario Valle
Data Analysis and Visualization Group            | 
http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)      | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82



More information about the R-help mailing list