Home > Net >  How to debug a "hidden" function in an R package?
How to debug a "hidden" function in an R package?

Time:01-30

can someone please help me understand this: I encountered an error when calling a function from a library, specifically "steinertree" from the "SteinerNet" package. When stepping into the function with debug(steinertree), I see that the error occurs, when the function in turn calls "steinertree3". When I try debug(steinertree3), I get "object 'steinertree3' not found". Similarly, I can get the code for 'steinertree' by typing it in the terminal, but not for 'steinertree3'. So it seems to me that there are some "higher-level" functions and "hidden" functions in packages. I did eventually find the error by finding a file "steinertree.R" in the package at CRAN, which contains both 'steinertree' and 'steinertree3', but I`m wondering how to properly go about debugging such "hidden" functions.

Here is a simple example:

library(igraph)
library(SteinerNet)

set.seed(1)
g= erdos.renyi.game(n=10,p.or.m=0.2)
plot(g)
steinertree(type= 'KB', terminals= c(1,3), graph= g)

Thank you!

CodePudding user response:

Use triple colon ::: to execute a function that is not exported by the package/namespace:

package:::hidden_function()
  • Related