[R] function to avoid <<-

Karim Mezhoud kmezhoud at gmail.com
Tue Dec 2 09:28:08 CET 2014


Dear All,

I am writing a GUIpackage that needs global variables.
I had many warning message when I checked the code as for example:
geteSet: no visible binding for global variable ‘curselectCases’
I would like to write a function that creates a global place for Objects to
be loaded as:


Fun <- function(){

Object <- 5

Var2Global <- function(Object){
.myDataEnv <- new.env(parent=emptyenv()) # not exported
isLoaded <- function(Object) {
    exists(Object, .myDataEnv)
}
getData <- function(Object) {
    if (!isLoaded(Object)) data(Object, envir=.myDataEnv)
    .myDataEnv[[Object]]
}
}

}

To avoid the use of:  Object <<- 5

but it seems not working yet. Object == 5 is not a global variable after
running Fun().

Any Idea?
Thanks
  Ô__
 c/ /'_;~~~~kmezhoud
(*) \(*)   ⴽⴰⵔⵉⵎ  ⵎⴻⵣⵀⵓⴷ
http://bioinformatics.tn/

	[[alternative HTML version deleted]]



More information about the R-help mailing list