[R] Document Paths in R.app

Andrew Simmons @kw@|mmo @end|ng |rom gm@||@com
Wed Jun 30 15:31:06 CEST 2021


Hello,


I've been writing a package that allows a script to know its path, and I've
been struggling to get it working for 'R.app' on macOS.

For 'Rgui' on Windows, I used 'utils::getWindowsHandles' to get the
script's path
[image: image.png]
but it's only on Windows, and even if it wasn't, it seems like 'R.app' only
stores the basename in the window handle, so this won't work.

For 'RStudio', they provide a function from the environment 'tools:rstudio'
that retrieves the script's path, and it seems like there's an equivalent
environment 'tools:RGUI' (you can find the source code at this URL:
https://github.com/R-macos/Mac-GUI/blob/5f6557eb9e921319586ac974db22cc1f74ba76ff/GUI-tools.R)
for 'R.app', but it claims to be for internal use only, and doesn't seem to
have a function for retrieving a document's path.

So my question, does anyone know of a way to retrieve the path of the
currently open document in 'R.app'? Thank you!

	[[alternative HTML version deleted]]



More information about the R-help mailing list