findSourceTraceback

0th

Percentile

Finds all 'srcfile' objects generated by source() in all call frames

Finds all 'srcfile' objects generated by source() in all call frames. This makes it possible to find out which files are currently scripted by source().

Keywords
programming, IO
Usage
## S3 method for class 'default':
findSourceTraceback(...)
Arguments
...
Not used.
Value

  • Returns a named list of objects of class 'srcfile'. The names of the list entries corresponds to the 'filename' value of each corresponding 'srcfile' object. The returned list is empty if source() was not called.

Aliases
  • findSourceTraceback.default
  • findSourceTraceback
Examples
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create two R script files where one source():s the other
# and both lists the traceback of filenames source():d.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
path <- tempdir();
pathnameA <- Arguments$getWritablePathname("foo.R", path=path);
pathnameB <- Arguments$getWritablePathname("bar.R", path=path);

code <- 'cat("BEGIN foo.R
")';
code <- c(code, 'print(findSourceTraceback());');
code <- c(code, sprintf('source("%s");', pathnameB));
code <- c(code, 'cat("END foo.R
")');
code <- paste(code, collapse="");
cat(file=pathnameA, code);

code <- 'cat("BEGIN bar.R
")';
code <- c(code, 'print(findSourceTraceback());');
code <- c(code, 'cat("END bar.R
")');
code <- paste(code, collapse="");
cat(file=pathnameB, code);


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Source the first file
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
source(pathnameA, echo=TRUE);
Documentation reproduced from package R.utils, version 1.7.3, License: LGPL (>= 2.1)

Community examples

Looks like there are no examples yet.