[R] Importing only one function from a package

Matthew Keller mckellercran at gmail.com
Sat Sep 29 01:36:01 CEST 2007


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


More information about the R-help mailing list