sourceutils
Source Reference Utilities
These functions extract information from source references.
- Keywords
- utilities
Usage
getSrcFilename(x, full.names = FALSE, unique = TRUE)
getSrcDirectory(x, unique = TRUE)
getSrcref(x)
getSrcLocation(x, which = c("line", "column", "byte", "parse"),
first = TRUE)
Arguments
- x
- An object (typically a function) containing source references.
- full.names
- Whether to include the full path in the filename result.
- unique
- Whether to list only unique filenames/directories.
- which
- Which part of a source reference to extract. Can be abbreviated.
- first
- Whether to show the first (or last) location of the object.
Details
Each statement of a function will have its own source reference if the
"keep.source"
option is TRUE
. These functions retrieve
all of them.
The components are as follows: [object Object],[object Object],[object Object],[object Object]
Value
getSrcFilename
andgetSrcDirectory
return character vectors holding the filename/directory.getSrcref
returns a list of"srcref"
objects orNULL
if there are none.getSrcLocation
returns an integer vector of the requested type of locations.
See Also
Examples
library(utils)
fn <- function(x) {
x + 1 # A comment, kept as part of the source
}
# Show the temporary file directory
# where the example was saved
getSrcDirectory(fn)
getSrcLocation(fn, "line")
Community examples
Looks like there are no examples yet.