Source a R script, only if the result has not already been stashed. The final
expression in the script is treated as the return value from the script (as
per the functionality of source()
, and this value is returned and
stashed (using stash()
as the underlying caching mechanism).
stash_script(script_path, depends_on = NULL, verbose = NULL)
Path (absolute or relative) to the script to source.
A vector of other objects that this one depends on. Changes to these objects will cause the re-running of the code next time.
Whether to print action statements (default TRUE).
The last line in the script referred to by the script at
script_path
is treated as a return value, and is returned and
cached.
This function always calls stash()
in functional mode.
Note that the stashed result is keyed according to the specified path to the script without any canonization. The function will therefore not realize that an absolute and relative path refer to the same file, and treat them as two separate results to cache.
The time of modification is also included in the key of the results so any modification to the file will result in the script being re-run on the next call.