[R] What file did R read?

Gabor Grothendieck ggrothendieck at myway.com
Mon Feb 21 19:13:39 CET 2005



A different workaround that avoids generating a file
would be to set an environment variable in your script:

set infile=%1

and then access infile using Sys.getenv within R.


Date:   Mon, 21 Feb 2005 16:38:57 +0100 
From:   BXC (Bendix Carstensen) <bxc at steno.dk>
To:   <r-help at stat.math.ethz.ch> 
Subject:   [R] What file did R read? 

 
When I run in BATCH mode I use a script (win2000):

c:\stat\r\%R_VERS%\bin\Rcmd BATCH -q --no-restore --no-save %1

Now I want to be able to print the filename of the program, i.e.
the value if the %1 argument, in the .Rout file. 

(Basically I want to write a piece of code in .First() which 
prints date and time and program run, so I need to get to the 
value of %1. Currently I let the operating system print the value 
of %1 to a file, and then read the contents of this file.
Clumsy, it works, but tricky to port to another machine.)

The commandArgs() does NOT capture the name of the input file.

Is it impossible to recover this filename from within R?

Bendix Carstensen




More information about the R-help mailing list