[R] debug(sum) error

Duncan Murdoch murdoch at stats.uwo.ca
Sun Oct 11 01:18:07 CEST 2009


On 10/10/2009 7:00 PM, Another Oneforyou wrote:
> Hi,
> I'm working through "R-debug-tools.pdf" and on page 7 it describes doing:
> Browse[1]> debug(sum) ## Flag sum for debugging
> however, when I try this, I get:
> Browse[1]> debug(sum)Error in debug(fun) : argument must be a closure
> Does anyone know why I get this error, and how to work around it?

debug() only works on regular functions (which are called "closures"). 
sum() is a special built in function, because it is so frequently used, 
and because it needs to be fast.  So you can't debug it.

Whoever wrote those instructions should update them to use a different 
example.  (Google suggests that the document was written in 2002, so 
someone may very well have already done so.)

Duncan




More information about the R-help mailing list