On 29/10/2010 5:19 PM, Andre Zege wrote:

Hi, everyone. I am using a fair amount of closures in my code. Problem i am
experiencing is i cannot figure out how to mtrace functions defined within a
function. There must be some way to name such function for mtrace to see it
and let me step into it. For example, say i have code


mymodel<-function(){
  data<-numeric(0)
  build<-function(){
    data<<-1
  }

  m<-list()
  m$build<-build
  m
}


How do I mtrace build function defined inside mymodel function so that i can
step into build?

I don't use mtrace, but you can use setBreakpoint() to set a breakpoint by line number, and presumably you could set the action to whatever will trigger mtrace. It will modify the source of mymodel so that every time it creates a new build(), it creates it with a breakpoint within.

See ?setBreakpoint and ?trace.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to