Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting windows to start R in batch mode using the Start command

I know I must be making a simple syntax mistake, but I want to have a windows batch file that fires up 9 instances of R and runs a different routine in each one. I want these to run simultaneously (i.e. asynchronously). I can fire up 9 command prompt windows and type a command in each one, but it seems like with the START command I should be able to make them start from a single batch file.

Here's an example of how I start one of the instances of R:

"C:\Program Files (x86)\R\R-2.8.1\bin\R" CMD BATCH "C:\Users\jd\Documents\mexico\Estado\getdata1.r" 

Reading this previous stackoverflow question along with this previous question makes me think I should be able to do this:

START "" "C:\Program Files (x86)\R\R-2.8.1\bin\R" CMD BATCH "C:\Users\jd\Documents\mexico\Estado\getdata1.r" /b

That does not return an error, it just returns a prompt and R never starts. What am I missing?

like image 374
JD Long Avatar asked Dec 22 '22 10:12

JD Long


1 Answers

I would do two things differently:

  1. Use R itself to dispatch nine different jobs; the snow package is very good at this even when do not use MPI / PVM / NWS for distributed work. Some examples for snow use are for example in my 'introduction to high performance computing with R' tutorials linked from this page. With snow, you get 'parallel' versions of the apply functions that you can run over multiple instances of R running on the local computer (or of course a network of computers if have one). The r-sig-hpc list is helpful for more detailed questions.

  2. Switch to using Rscript.exe instead of using 'R CMD BATCH'. On Linux / OS X you also get a choice of using littler

That said, I run almost all my jobs on Linux so there may be a Windows-specific answer here too that I just do not know. But the above is generic and stays in the platform-agnostic spirit of R.

like image 69
Dirk Eddelbuettel Avatar answered Jan 24 '23 10:01

Dirk Eddelbuettel