问题
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