[R] Importing only one function from a package

Søren Højsgaard Soren.Hojsgaard at agrsci.dk
Sat Sep 29 01:30:02 CEST 2007


Dear List
 
In a package I want to import the mApply function from the Hmisc package, and I would like to import only that function.
 
1) If I write "Depends: Hmisc" in the DESCRIPTION file I get the whole Hmisc package, so that is not the way to go ahead.
 
2) According to "Writing R extensions", sec 1.6.1 "Specifying imports and exports" I can (as I read it) simply type Hmisc:::mApply(....) in my code. That works, but gives a warning in the check:
 
* checking for unstated dependencies in R code ... WARNING
'::' or ':::' imports not declared from:
  Hmisc
 
3) According to the same section I can (again as I read it) write in the NAMESPACE file
importFrom(Hmisc,mApply)
 
Then I get:
 
* checking package dependencies ... ERROR
Namespace dependencies not required:
  Hmisc
 
That message goes away if I write  "Depends: Hmisc" in DESCRIPTION, but then we are back to 1) where I started where the whole Hmisc package is loaded.
 
Obviously I have missed a point or two somewhere. Can anyone enlighten me?
 
I use R 2.5.1 on windows XP.
 
Regards
Søren
 
 
 



More information about the R-help mailing list