Re: [R] debugging non-visible functions
On Wed, 13 Oct 2004, Murad Nayal wrote: 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? The issue here is a non-visible S3 method. In that case, just make a local copy: predict.rpart - rpart:::predict.rpart debug(predict.rpart) In general (not an S3 method), you cannot do this since the local copy may not be called, and the only way I know is to use fixInNamespace and insert browser() at the top. Even that may not always work. Luke Tierney recommends removing the NAMESPACE file during development of a package if you need frequent access to debug/change its functions. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] debugging non-visible functions
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? many thanks Murad Nayal __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] debugging non-visible functions
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 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html