Learn R Programming

scriptloc (version 1.0.0)

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

Description

Whenever a script is sourced into an R session using source(), the path of the file gets attached to the environment with the name ofile, which can be used to get the file path from within the script. If multiple files are being sourced before, then these would all be present in a different environment. Getting the ofile entry that comes last will give us the sourced file.

Usage

src_file_get(frames)

Arguments

frames

: This is the output from sys.frames()