Skip to content

Hidden variables

2 messages · Joel, Greg Snow

#
Hi Im trying to make a package in R just to learn how it works.

One thing I dont manage to do is to make a hidden environment or variable so
to say.

I want a "hash list" that I create my useing:

TestEnv<-new.env()
assign("Key1","Ans1",envir=TestEnv)
assign("Key2","Ans2",envir=TestEnv)

Then I just have this function to try it:

TestFunc<- function(Key, ...) UseMethod("TestFunc")

TestFunc.default <- function(Key,...){
Ans<-get(Key, envir=TestEnv)
print(Ans)
}

But when I load this package I can access the TestEnv by just typing
TestEnv, but I want this one hidden so that you only can get the "Ans" from
the "Key" via the TestFunc.

Thx for the help
Joel
1 day later
#
Create a namespace for your package, anything not exported will be "hidden" (though a determined person can still find it).