[R] File > Save As...

Duncan Murdoch murdoch.duncan at gmail.com
Tue Mar 15 23:32:11 CET 2011

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

More information about the R-help mailing list