[R-SIG-Mac] Retrieving Script Path in R.app

Thomas Hopper tomhopper @end|ng |rom gm@||@com
Sun Oct 10 17:10:37 CEST 2021


You may want to look at the “here” package. 

Sent from my iPhone

> On Oct 9, 2021, at 23:23, Andrew Simmons <akwsimmo using gmail.com> wrote:
> 
> Hello,
> 
> 
> I'd like to programmatically retrieve the path of the currently open script
> in R.app.
> Something like, if I had written:
> 
> this.path()
> 
> within a script that was open in R.app, and I ran that line with
> Command+Enter,
> I'd like it to return the path of the script.
> It seems like this should be possible since Command+E runs the following:
> 
> source("/absolute/path/to/file")
> 
> so R.app knows the path of the open script, but I was unable to find
> anything that would retrieve it on my own. First, I tried looking through
> the environment 'as.environment("tools:RGUI")', but I didn't find anything
> that looked like what I was looking for. Second, I tried comparing the
> functions available in the base packages between Windows and macOS, and
> while there are a few functions available for macOS that are not for
> Windows, none of them looked like what I was looking for.
> Any help will be greatly appreciated, thank you!
> 
> 
> Regards,
>    Andrew Simmons
> 
>    [[alternative HTML version deleted]]
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list