Is it possible to create a link class for log calls

I have a question about reference classes. My question is in the context of the R package that I am developing rCharts . It uses reference classes to create interactive graphs from R.

Creating a story involves a series of challenges. Here is an example where a scatter plot is created first, and then a line plot is added.

p1 <- rPlot(mpg ~ cyl, data = mtcars, type = 'point')
p1$layer(copy_layer = T, type = 'line')

Now, since the reference class looks like a closure, I was wondering if I managed to register the calls made. The idea is that if I can record the sequence of calls made, then I can automatically paste the source code used to create the visualization along with html.

I tried to find out if I can use sys.functionor match.call, but I do not get anywhere. If someone can tell me how I can do this, that would be very grateful.

+5
source share
1 answer

As @hadley said:

calls <<- c(calls, list(match.call()))

Glad it seemed to work. Let it be closed. :)

+2
source