get_script_dir_path: Gets the path of the script that runs it

Description Usage Arguments Value Limitations

View source: R/get_script_dir_path.R

Description

Function returns the path to the script that ran it. Can be used to put the script outputs right next to the script. If run inside a function it will return the script that ran that function. Helps to run at the top of a sourced function: sample_script_path = get_script_path() And then use that script name in the function default: example_function = function(script_path = sample_script_path){script_path} Designed to work if run as Rscript, sourced via RStudio or console, or run via RStudio. Found most of the inspiration for this here: https://stackoverflow.com/questions/1815606/rscript-determine-path-of-the-executing-script

Usage

1
2
get_script_dir_path(debug_mode = FALSE, sourced_file = TRUE,
  include_file_name = FALSE)

Arguments

debug_mode

Boolen on whether detailed messages should be output to help debug the code

sourced_file

Boolean on whether the files expects to be sourced or not. If so, and it's run as an rscript or sourced via the console it returns getwd.

include_file_name

Boolean on whther the file name should be reutrned if possible

Value

Returns the path to the script that ran it

Limitations


DanteBortone/housekeeping documentation built on April 20, 2020, 4:08 p.m.