[R] Namespace in packages

Duncan Murdoch murdoch.duncan at gmail.com
Thu Sep 1 13:06:51 CEST 2011


On 11-09-01 7:04 AM, Eran Eidinger wrote:
> Yes, the package works fine without the NAMESPACE file, and all 3 functions
> are visible.

When you include the NAMESPACE file, what does R CMD check tell you?

Duncan Murdoch

>
>
> On Thu, Sep 1, 2011 at 2:02 PM, Duncan Murdoch<murdoch.duncan at gmail.com>wrote:
>
>> On 11-09-01 2:27 AM, Eran Eidinger wrote:
>>
>>> Hello,
>>>
>>> I wonder how I might create a package that only reveals some of the
>>> function
>>> in the package to the user.
>>>
>>> I've tried creating an R package using the following:
>>> f<- function(x,y) x+y
>>> g<- function(x,y) x-y
>>> h<- function(x,y) f(x,y)*g(x,y)
>>>
>>> package.skeleton(list=c("f","**g","h"), name="mypkg")
>>>
>>> and would like only h() to be available when I load it, and exposed.
>>> I tried creating a file called NAMESPACE that has one line:
>>> export(h)
>>> But after running R CMD install, when I try to load it with:
>>> library("mypkg",lib.loc=...) i get "Error in namespaceExport(ns, exports)
>>> :
>>> undefined exports: h"/
>>> What am I doing wrong?
>>>
>>
>> Your description of what you did sounds like the right thing.
>>
>> Does your package work without the NAMESPACE file?  I.e. are all of f, g
>> and h visible?  I would guess there is something else wrong in it, and h is
>> really not there.
>>
>>
>>
>>   (BTW, side question, if, after loading, i overload f() or g() with a new
>>> definition from the R console, will h() be affected?)
>>>
>>
>> No.
>>
>> Duncan Murdoch
>>
>>
>>> Thanks,
>>> Eran Eidinger.
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> ______________________________**________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>>> PLEASE do read the posting guide http://www.R-project.org/**
>>> posting-guide.html<http://www.R-project.org/posting-guide.html>
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>
>



More information about the R-help mailing list