Re: [R] Hidden variables

2011-02-02 Thread Greg Snow
Create a namespace for your package, anything not exported will be "hidden" 
(though a determined person can still find it).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Joel
> Sent: Tuesday, February 01, 2011 7:28 AM
> To: r-help@r-project.org
> Subject: [R] Hidden variables
> 
> 
> 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
> --
> View this message in context: http://r.789695.n4.nabble.com/Hidden-
> variables-tp3251588p3251588.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Hidden variables

2011-02-01 Thread Joel

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
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Hidden-variables-tp3251588p3251588.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.