Learn R Programming

scriptloc: Get the location of the R script that is being sourced/executed

Provides functions to retrieve the location of R scripts loaded through the source function or run from the command line using the Rscript command. This functionality is analogous to the Bash shell's ${BASH_SOURCE[0]}. Users can first set the project root's path relative to the script path and then all subsequent paths relative to the root. This system ensures that all paths lead to the same location regardless of where any script is executed/loaded from without resorting to the use of setwd at the top of the scripts.

Copy Link

Version

Install

install.packages('scriptloc')

Monthly Downloads

175

Version

1.0.0

License

MIT + file LICENSE

Maintainer

Naren Chandran Sakthivel

Last Published

August 17th, 2023

Functions in scriptloc (1.0.0)

src_file_get

Get location of script that was loaded through the source() function
script_file_get

Get location of script that was executed through Rscript
scriptloc

Get location of script in a fashion analagous to $BASH_SOURCE[0]
script_dir_get

Return directory where the script exists