sourceutils

0th

Percentile

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 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.

See Also

srcref, getParseData

Aliases
  • getSrcFilename
  • getSrcDirectory
  • getSrcref
  • getSrcLocation
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")
Documentation reproduced from package utils, version 3.3, License: Part of R 3.3

Community examples

Looks like there are no examples yet.