[R] debugging non-visible functions

Gabor Grothendieck ggrothendieck at myway.com
Wed Oct 13 07:52:57 CEST 2004


Murad Nayal <mn216 <at> columbia.edu> writes:

: 
: Hi,
: 
: I would like to step-through a non-visible function. but apparently I
: don't know enough about namespaces to get that to work:
: 
: > methods(predict) 
:  ... deleted lines ... 
: [27] predict.rpart*             predict.smooth.spline*    
: [31] predict.survreg.penal*    
: 
:     Non-visible functions are asterisked
: 
: 
: > debug(predict.rpart)
: Error: Object "predict.rpart" not found
: 
: 
: > getAnywhere("predict.rpart")
: A single object matching 'predict.rpart' was found
: It was found in the following places
:   registered S3 method for predict from namespace rpart
:   namespace:rpart
: with value
: 
: function (object, newdata = list(), type = c("vector", "prob", 
:     "class", "matrix"), ...) 
: {
: ... deleted code ...
: }
: <environment: namespace:rpart>
: 
: 
: > debug(predict.rpart,pos="package:rpart")
: Error: Object "predict.rpart" not found
: 
: 
: how can I 'debug' non-visible functions, like predict.rpart?
: 

>From the ?debug page we see that that only one argument can
be given to debug, the function name, so there is no two
argument form as per your example above.

What you can do is that you can debug it like this:

   require(rpart)
   debug(rpart:::predict.rpart)

Also note that even if its not visible it may still have a help
page, which in this case it does:

   ?predict.rpart




More information about the R-help mailing list