NCEAS / recordr

Provenance tracking for R.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use `trace()` function to capture provenance

gothub opened this issue · comments

Currently recordr traces functions by inserting the recordr version of a function
on the search list ahead of user and R versions of the function. This practice is
extremely unpopular with the CRAN package reviewers

The base::trace() function can accomplish the same task, whereby a tracer
function is called after the traced function is entered (details a bit more complicated, but
this is essentially the idea). The traced function arguments are available to the tracer function.

So for example, to trace read.csv:

trace(utils::read.csv, recordr::recordr_read.csv)

Amd in recordr::recordr_read.csv():

...
# Get arguments of traced function
argList <- as.list(sys.call(which=1)
...

Multiple tracers can be defined at the same time, so that multiple functions can be
traced by recordr.

All current functions in tracedFunctions.R will be refactored to use base::trace()

Completed in commit a451ff7