On 11/12/2012 1:17 PM, Asis Hallab wrote:
Dear R experts,

recently I tried to debug a R function with an internal lapply call.
When debugging I seem not to be able to use the "n" command to debug the
inner function called by lapply.
How could I achieve this?

Jim gave you one solution. Another is to debug lapply, and when stepping through it, debug(FUN) after it is created on the first line. Jim's method is more convenient if you are particularly interested in a complicated function, this method is better if you are already in the middle of debugging and just want to look at a possibly anonymous function being passed to lapply.

Duncan Murdoch

*For example:*
test <- function( ) {
   lapply( 1:3, function( x ) x + 1 )
}
debug( test )

*Start debug:*
> test()
debugging in: test()
debug bei #1:{
     lapply(1:10, function(x) x + 1)
}
Browse[2]> n
debug bei #2:lapply(1:10, function(x) x + 1)

*The next "n" does not allow me to inspect the inner function,*
*but gives me the result directly:*
Browse[2]> n
exiting from: test()
[[1]]
[1] 2

[[2]]
[1] 3

[[3]]
[1] 4

Can anyone help me, please?
Kind regards!

        [[alternative HTML version deleted]]

______________________________________________
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.

______________________________________________
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