Hi -

I'm curious if there is a way to get access to the location of the calling
script within R.  I found one way of accessing it from this thread,
https://stat.ethz.ch/pipermail/r-devel/2008-April/048914.html, which
recommends using either:

parent.frame(2)$ofile

Or


FILE <- (function() {
  attr(body(sys.function()), "srcfile")
})()$filename


However, those suggestions only work when you source a script from within
the actual R shell, itself.  They will both fail, though, if you try to use
them within an executable Rscript using the shebang format (i.e.
#!/usr/bin/Rscript or #!/usr/bin/env Rscript).

Is there any way to get access to the actual file location if you are using
an executable R script?  I'm asking b/c I'd like to use an R script that
I've written for use w/in a workflow environment (Galaxy, to be specific).
 Because Galaxy places the executables within a user-specified directory,
we can't hard-code that location if we want these to be general purpose,
and would like access to that within the script, themselves, because in
some cases, they need to be able to access each other.

Thanks,

-- 
Peter Waltman, Ph.D.
pwaltman@ucsc.edu
617.347.1876

	[[alternative HTML version deleted]]

