search for: tracefnc

Displaying 2 results from an estimated 2 matches for "tracefnc".

2009 Apr 13
2
Using trace
I would like to trace functions, displaying their arguments and return value, but I haven't been able to figure out how to do this with the 'trace' function. After some thrashing, I got as far as this: fact <- function(x) if(x<1) 1 else x*fact(x-1) tracefnc <- function() dput(as.list(parent.frame()), # parent.frame() holds arg list control=NULL) trace("fact",tracer=tracefnc,print=FALSE) but I couldn't figure out how to access the return value of the function in the 'exit' p...
2009 Apr 13
2
Using trace
I would like to trace functions, displaying their arguments and return value, but I haven't been able to figure out how to do this with the 'trace' function. After some thrashing, I got as far as this: fact <- function(x) if(x<1) 1 else x*fact(x-1) tracefnc <- function() dput(as.list(parent.frame()), # parent.frame() holds arg list control=NULL) trace("fact",tracer=tracefnc,print=FALSE) but I couldn't figure out how to access the return value of the function in the 'exit' p...