How directly access S3 method in roxygen2 R package

落花浮王杯 提交于 2020-01-16 00:47:13

问题


I'm writing my first package with roxygen2. The package implements a faster version of pcdtest() from plm package. Thus I call within my package:

merr <- resid(mod)

Package plm implements a S3 method for resid. It exports it in plm's NAMESPACE this way:

S3method("residuals", "panelmodel")
S3method("residuals", "plm")

To be able to use resid(), I import whole plm package via

#' @import plm

Is there any way to access the proper method directly via ::? Or to import just the method? Or other nicer workaround?

Many thanks, Michal


回答1:


Late, but... Packages don't need to be attached for their registered S3 methods to be available, they just need to be loaded. Therefore, you don't need necessarily to import(plm) (which loads and attaches the package), but just to importFrom(plm, somefunction) (which loads the package, but attaches just this function), any function or symbol declared as export(somefunction) in plm's NAMESPACE.



来源:https://stackoverflow.com/questions/32680169/how-directly-access-s3-method-in-roxygen2-r-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!