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
Hi Soren, What I do in cases like this is just copy the function and place it into my script at the top (or write it into its own source file and call it from script). Best, Matt On 9/28/07, S?ren H?jsgaard <Soren.Hojsgaard at agrsci.dk> wrote:> 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 > > > > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Matthew C Keller Postdoctoral Fellow Virginia Institute for Psychiatric and Behavioral Genetics
On 9/28/07, S?ren H?jsgaard <Soren.Hojsgaard at agrsci.dk> wrote:> 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?For both 2) and 3), the correct DESCRIPTION entry is Imports: Hmisc And for 2), you should be able to use Hmisc::mApply (i.e., 2 colons, not 3), although 3) is preferred. -Deepayan
Apparently Analagous Threads
- Over-writing functions from other packages? What is a good strategy??
- Fwd: How to sample from a linear mixed model
- Calling substitute(expr, list(a=1)) when expr <- expression(a+b+c)
- Drawing a graph with vertices and edges using tcl/tk
- Computer algebra in R - would that be an idea??