Xianming Wei
2009-Mar-02 23:22 UTC
[R] how to pass a command variable in DOS to R program in R CMD BATCH
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}}
Gabor Grothendieck
2009-Mar-03 03:24 UTC
[R] how to pass a command variable in DOS to R program in R CMD BATCH
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. >