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
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
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,
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