Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

thisfile

Determines the path of the currently running script


Description

Soft-deprecated lifecycle

R does not store nor export the path of the currently running script. This is an attempt to circumvent this limitation by applying heuristics (such as call stack and argument inspection) that work in many cases. CAVEAT: Use this function only if your workflow does not permit other solution: if a script needs to know its location, it should be set outside the context of the script if possible.

Usage

thisfile()

thisfile_source()

thisfile_r()

thisfile_rscript()

thisfile_knit()

Details

This functions currently work only if the script was sourced, processed with knitr, or run with Rscript or using the --file parameter to the R executable. For code run with Rscript, the exact value of the parameter passed to Rscript is returned.

Value

The path of the currently running script, NULL if it cannot be determined.

Life cycle

These functions are now available in the whereami package.

Author(s)

Kirill Müller, Hadley Wickham, Michael R. Head

References

See Also

Examples

## Not run: 
thisfile()

## End(Not run)

rprojroot

Finding Files in Project Subdirectories

v2.0.2
MIT + file LICENSE
Authors
Kirill Müller [aut, cre] (<https://orcid.org/0000-0002-1416-3412>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.