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:

line

The line number where the object starts or ends.

column

The column number where the object starts or ends.

byte

As for "column", but counting bytes, which may differ in case of multibyte characters.

parse

As for "line", but this ignores #line directives.

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) # NOT RUN { 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.6.1, License: Part of R 3.6.1

Community examples

Looks like there are no examples yet.