| this.path-package {this.path} | R Documentation |
Get Script's Path
Description
Determine the path of the executing script.
Compatible with a few popular GUIs:
Compatible with several functions and packages:
source()debugSource()in ‘RStudio’box::use()
Details
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 ofthis.path().here()constructs file paths againstthis.dir().this.proj()constructs file paths against the project root ofthis.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=FILEset.sys.path()implementsthis.path()for anysource()-like functions outside of the builtins.with_init.file()allowsthis.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(), anddirname2()are drop in replacements forfile.path(),basename(), anddirname()which better handle drives and network shares.splitext(),removeext(),ext(), andext<-()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(), andpath.unsplit()split the path to a file into components.relpath(),rel2here(), andrel2proj()turn absolute paths into relative paths.
Note
This package started from a stack overflow posting:
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
bug.report(package = "this.path") to
report your issue.
Author(s)
Iris Simmons
Maintainer: Iris Simmons <ikwsimmo@gmail.com>