There's a definitive guide for how to view the source code for a function, but how do you debug a function that's not exported from a package, without manually stepping through the source code that you've found?
library(plm)
> predict.plm
Error: object 'predict.plm' not found
> plm:::predict.plm
function (object, newdata = NULL, ...)
{
tt <- terms(object)
if (is.null(newdata)) {
result <- fitted(object, ...)
}
else {
Terms <- delete.response(tt)
m <- model.frame(Terms, newdata)
X <- model.matrix(Terms, m)
beta <- coef(object)
result <- as.numeric(crossprod(beta, t(X)))
}
result
}
<environment: namespace:plm>
> debugonce("predict.plm")
Error in debugonce("predict.plm") : could not find function "predict.plm"
> debugonce("plm:::predict.plm")
Error in debugonce("plm:::predict.plm") :
could not find function "plm:::predict.plm"