powered by
These functions extract information from source references.
getSrcFilename(x, full.names = FALSE, unique = TRUE) getSrcDirectory(x, unique = TRUE) getSrcref(x) getSrcLocation(x, which = c("line", "column", "byte", "parse"), first = TRUE)
An object (typically a function) containing source references.
Whether to include the full path in the filename result.
Whether to list only unique filenames/directories.
Which part of a source reference to extract. Can be abbreviated.
Whether to show the first (or last) location of the object.
getSrcFilename and getSrcDirectory return character vectors holding the filename/directory.
getSrcFilename
getSrcDirectory
getSrcref returns a list of "srcref" objects or NULL if there are none.
getSrcref
"srcref"
NULL
getSrcLocation returns an integer vector of the requested type of locations.
getSrcLocation
Each statement of a function will have its own source reference if the "keep.source" option is TRUE. These functions retrieve all of them.
"keep.source"
TRUE
The components are as follows:
The line number where the object starts or ends.
The column number where the object starts or ends.
As for "column", but counting bytes, which may differ in case of multibyte characters.
"column"
As for "line", but this ignores #line directives.
"line"
#line
srcref, getParseData
srcref
getParseData
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")
Run the code above in your browser using DataLab