[R] Current script name from R

Allan Engelhardt allane at cybaea.com
Fri Jul 9 13:11:09 CEST 2010


I'm assuming you are using Rscript (please provide self-contained 
examples when posting) in which case you could look for the element in 
(base|R.utils)::commandArgs() that begin with the string "--file=" - the 
rest is the file name.  See the asValues= parameter in 
help("commandArgs", package="R.utils") for a nice way to get the parameter.

For an invocation of the form R < foo.R you'd need to inspect your 
system's process table (so don't do that).

Hope this helps.

Allan

On 09/07/10 10:48, Ralf B wrote:
> Is there a way for a script to find out about its own name ?
>
> Ralf
>
> ______________________________________________
> 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