[R] how to pass a command variable in DOS to R program in R CMD BATCH

Gabor Grothendieck ggrothendieck at gmail.com
Tue Mar 3 04:24:23 CET 2009


Create a file test.R containing this single line:

  print(commandArgs(TRUE))

and then try this:

  Rscript test.R a b c




On Mon, Mar 2, 2009 at 6:22 PM, Xianming Wei <Xwei at bses.org.au> wrote:
> Hi all,
>
>
>
> I need to run a program (asreml) thousands of times and each time I have
> to provide a slightly different dataset. Because I have to run asreml
> under Windows (DOS or scripts) environment, I have trouble to pass a
> command variable (or pointer variable or %counter in the following
> example) to R program so at each counter R can generate a different data
> set for asreml to run. Any suggestion appreciated.
>
>
>
> @echo off
>
> set /a counter=0
>
> :numbers
>
>
>
> R CMD BATCH generate.data.R [I don't know how I can pass %counter to
> generate.data.R]
>
> asreml asreml.program
>
> R CMD BATCH collate.results.R
>
>
>
> print %counter
>
>
>
> set /a counter=%counter%+1
>
> if %counter% ==15360 (goto :eof) else (echo %counter% >> C:\count.txt)
>
> goto :numbers
>
>
>
>
>
> Regards,
>
> Xianming
>
>
>
>
>
> DISCLAIMER:\ For details of our e-mail disclaimer, pleas...{{dropped:24}}
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list