[R] Namespace in packages

Eran Eidinger
2011-09-01T06:27:56Z

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?


(BTW, side question, if, after loading, i overload f() or g() with a new
definition from the R console, will h() be affected?)

Thanks,
Eran Eidinger.

	[[alternative HTML version deleted]]