함수의 소스 코드를 보는 방법은 definitive guide입니다.하지만 찾은 소스 코드를 수동으로 실행하지 않고 패키지에서 내 보낸 함수를 어떻게 디버깅합니까? 내가 사용했던수출되지 않은 기능을 디버깅하는 방법은 무엇입니까?
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"
(+1)이 분명하지만, 전혀가요 내가 현재 R 확장을 작성하는 것을 배우고 있기 때문에 위대한 (그리고 유용한) 질문이다. 고마워! –