问题
I would like to use one function from a package called myPackage
called as.data.frame.mywhateverS3class
When I look at the package NAMESPACE it looks as follows: S3method(as.data.frame, mywhateverS3class)
I would like to use this function inside another package. What I would normally do is specify this in roxygen2
as @import myPackage such that this generates import(myPackage)
inside the other package. That works.
But in this case I would like not to import the whole package but only the S3 method.
When I specify importFrom(myPackage, as.data.frame)
, or importFrom(myPackage, as.data.frame.mywhateverS3class)
this fails as as.data.frame is not exported in myPackage
and as.data.frame.mywhateverS3class is hidden when I type methods(as.data.frame)
Do I really need to import the whole package NAMESPACE for this? I'm looking at http://cran.r-project.org/doc/manuals/R-exts.html and can't seem to find how to restrict the import to just the S3method without importing the whole NAMESPACE. Is there a way to do this?
来源:https://stackoverflow.com/questions/23112762/what-is-the-correct-way-to-import-an-s3-method-without-importing-the-whole-packa