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

2021-10-10 Thread Duncan Murdoch
See https://stackoverflow.com/a/47045368/2554330 for a risky-looking method. I think the non-RStudio method is equivalent to this function: this.path <- function() { sys.frame(-5)$srcfile } which works for me using Cmd-E, but of course it doesn't work using Cmd-Enter, because that doesn't

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

2021-10-10 Thread Andrew Simmons
getSrcDirectory is fine, but it only works when using 'source' with 'keep.source = TRUE', so it severely limits how I can run my scripts. I've made a function / / package called this.path which returns the path of the executing script, and right now it works from Rscript, when using source, when

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

2021-10-10 Thread Ben Tupper
Hi, Would ?getSrcDirectory help? Ben On Sat, Oct 9, 2021 at 11:23 PM Andrew Simmons 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,

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

2021-10-10 Thread Thomas Hopper
You may want to look at the “here” package. Sent from my iPhone > On Oct 9, 2021, at 23:23, Andrew Simmons 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