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


Question

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?

1
4
5/23/2017 12:07:10 PM

Accepted Answer

Simple answer. On windows when running command use "Rcmd" not "R CMD". There is a separate exe for running the commands. Look in the bin folder of your R installation.

4
8/6/2010 1:04:26 AM

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.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon