[R-pkg-devel] Help needed to setting custom packages for R 3.1.2

sbihorel Sebastien.Bihorel at cognigencorp.com
Wed Jul 15 15:30:44 CEST 2015


Hi Duncan,

So if the NAMESPACE of a package contains exportPattern("^[^\\.]"), does 
this mean that only the functions created within the package are 
exported and that the functions that were imported are not exported?

On 7/15/2015 9:24 AM, Duncan Murdoch wrote:
> On 15/07/2015 9:07 AM, sbihorel wrote:
>> Hi,
>>
>> I saw a few recent posts on topics related to mine (eg
>> https://stat.ethz.ch/pipermail/r-package-devel/2015q3/000238.html). It
>> looks like I need to import more packages in my NAMESPACE, correct?
>>
>> However, I thought that imports would be recursive, ie imports would
>> also get the info from dependent packages.
> I haven't been following this thread, but the 2nd para above makes it
> sound as though an explanation of the NAMESPACE directives would be helpful.
>
> If you say
>
>   importFrom(Hmisc, latex)
>
> it acts as though you have made a copy of the Hmisc::latex function
> within your package environment.  (It isn't exported, unless you ask to
> export it.)
>
> If you say
>
>   import(Hmisc)
>
> it acts as though you have made copies of every exported function from
> Hmisc within your package environment.  This is why we recommend
> importing only the functions you need; otherwise your package
> environment gets bloated.
>
> No recursive copies are made, unless Hmisc happens to import something
> and re-exports it.
>
> When I say "acts as though", I don't mean it literally makes copies; it
> implements this in a more efficient way, basically only copying pointers
> to those functions -- but from a user point of view, you shouldn't be
> able to tell the difference, since you're not allowed to modify
> Hmisc::latex.
>
> Duncan Murdoch
>
>
>> Sebastien
>>
>>
>> On 7/13/2015 9:42 PM, sbihorel wrote:
>>> Hi,
>>>
>>> Sorry about the table. It looked good when displayed using a fixed
>>> width font. Let me try to linearize it:
>>>
>>>    * pkgA
>>>        o DESCRIPTION:
>>>            + Depends: methods, lattice, grid, gam
>>>            + Imports: Hmisc, survival
>>>        o NAMESPACE:
>>>            + import: lattice, grid, gam, methods
>>>            + importFrom: Hmisc (one function)
>>>    * pkgB
>>>        o DESCRIPTION:
>>>            + Depends: pkgA
>>>            + Imports: <nothing>
>>>        o NAMESPACE:
>>>            + import: pkgA
>>>            + importFrom: <nothing
>>>    * pkgC
>>>        o DESCRIPTION:
>>>            + Depends: methods, pkgB
>>>            + Imports: <nothing>
>>>        o NAMESPACE:
>>>            + import: methods, pkgB
>>>            + importFrom: <nothing
>>>
>>> Regarding the export, pkgA, pkgB, and pkgC NAMESPACE files include:
>>> exportPattern("^[^\\.]").
>>>
>>> Sebastien
>>>
>>>
>>> On 7/13/2015 5:36 PM, Seth Wenchel wrote:
>>>> Are you exporting the functions from pkgB and pkgC? It's hard to tell
>>>> from your table below. The easiest way is to add a comment before
>>>> each of the functions in pkgB and pkgC that you want to expose to the
>>>> users.
>>>>
>>>> #' @export
>>>> foo <- function(){...}
>>>>
>>>> Then run roxygen::roxygenise() to build the NAMESPACE file.
>>>>
>>>> HTH
>>>> Seth
>>>>
>>>> On Monday, July 13, 2015, sbihorel
>>>> <Sebastien.Bihorel at cognigencorp.com
>>>> <mailto:Sebastien.Bihorel at cognigencorp.com>> wrote:
>>>>
>>>>      Hi,
>>>>
>>>>      My group has recently upgraded from a fairly old R version (2.12)
>>>>      to the
>>>>      R version 3.1.2. In parallel to this upgrade, I am updating our
>>>>      custom
>>>>      packages to add functionality and also make them compliant to the
>>>>      requirements of the new version of R. I would like to ask your
>>>>      help with
>>>>      respect to warning messages I get when I check and install the
>>>>      packages.
>>>>      I read the latest version of the manual on writing R extensions,
>>>>      try to
>>>>      apply the recommendations, but somehow I am not getting things right.
>>>>      Hopefully, with your suggestions, I could setup my package
>>>>      correctly to
>>>>      make these messages stop.
>>>>
>>>>      I apologize but, for confidentiality purpose, I will have to
>>>>      partially
>>>>      anonymize the information.
>>>>
>>>>      So here is the situation: we have 2 custom packages (let's call them
>>>>      pkgB and pkgC). The pkgB package depends on a 3rd package (let's
>>>>      call it
>>>>      pkgA) that is available on CRAN. The pkgC package depends on
>>>>      pkgB, make
>>>>      new function available,  and "overwrites" some of the functions
>>>>      distributed as part of pkgA. The following table summarizes the
>>>>      content
>>>>      of the DESCRIPTION and NAMESPACE files of each of these packages.
>>>>
>>>>      package    DESCRIPTION NAMESPACE
>>>>                  Depends                       Imports
>>>>      import                         importFrom
>>>>      pkgA       methods, lattice, grid, gam   Hmisc, survival lattice,
>>>>      grid,
>>>>      gam, methods    Hmisc
>>>>      pkgB       pkgA pkgA
>>>>      pkgC       methods, pkgB methods, pkgB
>>>>
>>>>      I do not get any warning when I build, check or install pkgB in our
>>>>      linux openSuse environment.
>>>>
>>>>      After successful building pkgC, I run R CMD check on my built for
>>>>      pkgC
>>>>      but I get a ton of messages under the "checking R code for possible
>>>>      problems" section. These notes are related to actual calls to pkgA
>>>>      functions (or to one of the function provided by its
>>>>      dependencies). Here
>>>>      is a subset for illustration and hopefully information.
>>>>
>>>>      * checking R code for possible problems: NOTE
>>>>      pkgC_function_001: no visible global function definition
>>>>      for"pkgA_function_AAA"
>>>>      pkgC_function_001: no visible global function definition
>>>>      for"pkgA_function_AAB"
>>>>      ...
>>>>      pkgC_function_010: no visible global function definition for"xyplot"
>>>>      pkgC_function_010: no visible global function definition
>>>>      for"panel.xyplot"
>>>>      pkgC_function_010: no visible global function definition
>>>>      for"panel.abline"
>>>>      pkgC_function_010: no visible global function definition
>>>>      for"grid.polygon"
>>>>      pkgC_function_010: no visible global function definition for"gpar"
>>>>      ...
>>>>
>>>>      Now when I try to install the pkgC_0.0.1.tar.gz package, I get the
>>>>      following warnings about the content of my documentation Rd
>>>>      files. The
>>>>      Rd files of pkgC includes links to lattice, grid, or pkgA functions.
>>>>
>>>>      *** installing help indices
>>>>         converting help for package âkiwixposedevâ
>>>>           finding HTML links ... done
>>>>      pkgC_function_001                    html
>>>>           pkgC_function_002                    html
>>>>      ...
>>>>      Rd warning: /tmp/some/path/man/pkgC_function_009.Rd:21: missing file
>>>>      link "panel.abline"
>>>>      ...
>>>>      Rd warning: /tmp/some/path/man/pkgC_function_015.Rd:64: missing file
>>>>      link "pkA_function_AAC"
>>>>      ...
>>>>
>>>>      I think I need to somehow modify the content of the DESCRIPTION and
>>>>      NAMESPACE files for pkgC... but adding various combinations of
>>>>      pkA and
>>>>      its dependencies gave me others errors about redundancies and
>>>>      multiple
>>>>      loading of the same packages. So in short, I am kind of lost with the
>>>>      new requirements of R 3.1.2 and would greatly appreciate any help or
>>>>      suggestions
>>>>
>>>>      Thank you in advance for your time.
>>>>
>>>>      Sebastien Bihorel
>>>>
>>>>
>>>>              [[alternative HTML version deleted]]
>>>>
>>>>      ______________________________________________
>>>>      R-package-devel at r-project.org <javascript:;> mailing list
>>>>      https://stat.ethz.ch/mailman/listinfo/r-package-devel
>>>>



More information about the R-package-devel mailing list