On 15/03/2011 4:45 PM, Hadley Wickham wrote:
The bigger issue is that R can't tell the location of an open script,
which makes it harder to create new versions of existing work....
But it can. If you open a script and choose save, it will be saved to the
same place. Or do you mean an executing script? There are indirect ways to
find the name of the executing script. For example,
in R-devel (to become 2.13.0 next month), you can do this:
cat("This file is ", getSrcFilename(function(){}, full=TRUE), "\n")
The getSrcFilename() function will be new in 2.13.0. You can do the same in
earlier versions, but you need to program it yourself.
Could getSrcFilename() gain a default argument so that
getSrcFilename() would by default return the path of the executing
script?
No, it needs to see a function defined in that script.
Duncan Murdoch
______________________________________________
R-help@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.