[R] Debug problem

Gabor Grothendieck ggrothendieck at myway.com
Wed Apr 21 06:35:24 CEST 2004


Excellent!  Thanks.

Duncan Murdoch <dmurdoch <at> pair.com> writes:

: 
: On Wed, 21 Apr 2004 00:47:55 +0000 (UTC), Gabor Grothendieck
: <ggrothendieck <at> myway.com> wrote:
: 
: >Thanks.  Your hypothesis does seem likely.  In
: >
: >g <- f; environment(g) <- new.env()
: >
: >is there any way that I can automatically set g to have debugging 
: >iff f has it?
: 
: undebug() gives a warning if the function doesn't have the debug flag
: set, so it's possible to do it.  I'm new to the new signals in R, so
: this might be a really ugly implementation, but here goes:
: 
: isbeingdebugged <- function(f) {
:     if (is.function(f)) {
:         result <- tryCatch(undebug(f), warning = function(w) 1)
: 	  result <- is.null(result)
: 	  if (result) debug(f)
: 	  result
:     } else stop('Not a function')
: }
: 
: copydebugstatus <- function(f, g) {
:    if (isbeingdebugged(f)) debug(g)
:    else if (isbeingdebugged(g)) undebug(g)
: }
: 
: Duncan Murdoch
: 
: ______________________________________________
: R-help <at> stat.math.ethz.ch mailing list
: https://www.stat.math.ethz.ch/mailman/listinfo/r-help
: PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
: 
:




More information about the R-help mailing list