[R] Using "Rscript" in combination with "eval()" results in error

Janko Thyson janko.thyson at ku-eichstaett.de
Thu Feb 11 16:25:47 CET 2010

Dear List,

I'm having trouble running a .bat file which calls an R-Script via the
command line (using "Rscript").

I put the following line in a file called "test.bat":

Rscript --vanilla test.R

Then I tried to launch "test.bat" via Windows' CMD (I plan to make this a
scheduled Windows task).

The actual R-script ("test.R") is executed just fine until it gets to a line
containing an eval() expression:


and R (or Windows' CMD, respectively) throws the following error

Error in if (file == "") <- stdin() else { : Argument is of length 0
Calls: source -> eval.with.vis -> eval.wtih.vis -> source
Execution stopped

Usually such "eval()" expressions work just fine in my scripts.

I tried the following already:
1) to.load.file <- file("C:/temp/another.script.R", open="rt");
eval(parse(file=to.load.file): No luck
2) Running "test.R" within a Rterm session: Works fine.
3) Calling the following from within a Rterm session:

system("Rscript C:/temp/test.R", wait=TRUE, invisible=FALSE)

That works too!

Is there something one needs to be aware of regarding "eval()" or "source()"
when launching a script via a CMD call to a .bat file?

Im running Windows XP and R-2.10.1

Any hints greatly appreciated!


More information about the R-help mailing list