Determine the path of the executing script.
Compatible with several popular GUIs:
‘Rgui’
‘RStudio’ (including background jobs)
‘Positron’
‘VSCode’ + ‘REditorSupport’
‘Jupyter’
‘Rscript’
(shell)
Compatible with several functions and packages:
debugSource() in ‘RStudio’
box::use()
plumber::plumb()
Iris Simmons [aut, cre]
Maintainer: Iris Simmons <ikwsimmo@gmail.com>
The most important functions from package:this.path are
this.path(), this.dir(), here(),
and this.proj():
this.path() returns the normalized path of the script
in which it is written.
this.dir() returns the directory of
this.path().
here() constructs file paths against
this.dir().
this.proj() constructs file paths against the project
root of this.dir().
New additions include:
LINENO() returns the line number of the executing
expression.
shFILE() looks through the command line arguments,
extracting FILE from either of the following: -f
FILE or --file=FILE
set.sys.path() implements this.path() for
any source()-like functions outside of the builtins.
with_init.file() allows this.path() and related
to be used in a user profile.
package:this.path also provides functions for constructing and manipulating file paths:
path.join(), basename2(), and
dirname2() are drop in replacements for
file.path(), basename(), and
dirname() which better handle drives and
network shares.
splitext(), removeext(),
ext(), and ext<-() split a path into root and
extension, remove a file extension, get an extension, or set an extension
for a file path.
path.split(), path.split.1(), and
path.unsplit() split the path to a file into components.
relpath(), rel2here(), and
rel2proj() turn absolute paths into relative paths.