[R] Namespace in packages
murdoch.duncan at gmail.com
Thu Sep 1 13:02:59 CEST 2011
On 11-09-01 2:27 AM, Eran Eidinger wrote:
> 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:
> 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?)
> Eran Eidinger.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help