| sourceutils {utils} | R Documentation |
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)
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. |
first |
Whether to show the first (or last) location of the object. |
Each statement of a function will have its own source reference if
options(keep.source=TRUE). These functions retrieve all of them.
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.
As for "line", but this ignores #line directives.
getSrcFilename and getSrcDirectory return character vectors
holding the filename/directory.
getSrcref returns a list of "srcref" objects or
NULL if there are none.
getSrcLocation returns an integer vector of the requested type
of locations.
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")