Klaus
Klaus

Reputation: 2056

How to debug functions they called via eval etc

I dont know how to debug structures like:

fun1 <- function(obj){
   a<-c(obj,4)
   c(a,5)
}

fun <- function(obj){
   a <- match.call()
   a[[1L]] <- fun1
   return(eval.parent(a))
}

I would like to know how to instruct the debug-mode to follow the call eval.parent(a) and jump into fun1.

Upvotes: 2

Views: 116

Answers (1)

IRTFM
IRTFM

Reputation: 263352

Per the debug help page: "If you want to debug a function not starting at the very beginning, use trace(..., at = *) or setBreakpoint."

> trace(eval.parent)

> fun(4)
trace: eval.parent(a)
[1] 4 4 5

Or perhaps you want to raise a warning and use that to trigger the browser. Hard to tell at this point what you are expecting.

Upvotes: 1

Related Questions