Suppose I'm developing a package, called foo
, which would like to use the description
function from the memisc
package. I don't want to import the whole memisc
namespace because :
- It is bad
memisc
overrides the baseaggregate.formula
function, which breaks several things. For example,example(aggregate)
would fail miserably.
The package includes the following files :
DESCRIPTION
Package: foo
Version: 0.0
Title: Foo
Imports:
memisc
Collate:
'foo.R'
NAMESPACE
export(bar)
importFrom(memisc,description)
R/foo.R
##' bar function
##'
##' @param x something
##' @return nothing
##' @importFrom memisc description
##' @export
`bar` <- function(x) {
description(x)
}
I'd think that using importFrom
would not load the entire memisc
namespace, but only namespace::description
, but this is not the case. Starting with a vanilla R :
R> getS3method("aggregate","formula")
## ... function code ...
## <environment: namespace:stats>
R> library(foo)
R> getS3method("aggregate","formula")
## ... function code ...
## <environment: namespace:memisc>
R> example(aggregate)
## Fails
So, do you know how I can import the description
function from memisc
without getting aggregate.formula
in my environment ?
::
man page says that using it will load the entire namespace, I already tested it. – jubaaggregate.formula
frommemisc
:memisc::description ; getS3method("aggregate","formula")
. – jubaaggregate.formula
. – joran