| this.path-package | R Documentation |
Determine the path of the executing script.
Compatible with several popular GUIs:
‘Rgui’
‘\RStudio’ (including background jobs)
‘\Positron’
‘\VSCode’ + ‘\REditorSupport’
‘\Jupyter’
‘\Emacs’ + ‘\ESS’
‘\Rscriptlink’ (shell)
Compatible with several functions and packages: \syspathcompatiblelinks
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 \sourcelink-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
\codelink3basefile.path(), \codelink3basebasename(), and
\codelink3base:basenamedirname() 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.
This package started from a stack overflow posting:
\Sexpr[results=rd,stage=install]{if (getRversion() >= "3.0.0") "\\\href{https://stackoverflow.com/questions/1815606/determine-path-of-the-executing-script/64129649#64129649}{https://stackoverflow.com/questions/1815606/determine-path-of-the-executing-script/64129649#64129649}" else "\\\ifelse{latex}{\\\href{https://stackoverflow.com/questions/1815606/determine-path-of-the-executing-script/64129649}{https://stackoverflow.com/questions/1815606/determine-path-of-the-executing-script/64129649}}{\\\href{https://stackoverflow.com/questions/1815606/determine-path-of-the-executing-script/64129649#64129649}{https://stackoverflow.com/questions/1815606/determine-path-of-the-executing-script/64129649#64129649}}"}If you like this package, please consider upvoting my answer so that more people will see it! If you have an issue with this package, please use \codelink3utils:bug.reportbug.report(package = "this.path") to report your issue.
Iris Simmons [aut, cre]
Maintainer: Iris Simmons <ikwsimmo@gmail.com>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.