[R-sig-hpc] how to get job index into R?

Dirk Eddelbuettel edd at debian.org
Tue Nov 3 13:36:06 CET 2009


On 3 November 2009 at 10:50, Unger, Kristian wrote:
| Hi there!
| 
| I am fairly new to HPC therefore I am asking a pretty basic question. I would like to submit a job array which uses one single R script. The R script uses one dataset which I want to analyse a defined set of say 100 sets of variables. Which variables to choose should be determined by the job array index number. But how can the job index number handed over to the R script? Would this concept work out at all?

One common approach is to enumerate the set of variable or values in a data
structure and to then unroll that data.structure.  E.g.

R> z <- 1:9
R> sapply(z, function(x) x^2)
[1]  1  4  9 16 25 36 49 64 81
R> 

Conceptually, parallel computing is the same:  create a data structure 'z',
and then use anything from, say, mclapply (from multicore) or parSapply (from
snow) to unroll the computing of a function over z as I did here.

See e.g. my 'Intro to HPC with R' tutorial slides for more examples.

Cheers, Dirk
 
-- 
Three out of two people have difficulties with fractions.



More information about the R-sig-hpc mailing list