Hello, I'm a newbie to R, I have a quesiton. I'm a bit confused on global variable assignments. I have the following situation. I have 2 global variables current_idx and previous_idx. *These 2 global variables have to be set by a method in a reference class*. Essentially, using <<- assignment operator should work right ? But, I get this warning Non-local assignment to non-field names (possibly misspelled?) Where am I going wrong ? Will assign(current_idx, index, envir = .GlobalEnv) work ? Thanks ! [[alternative HTML version deleted]]
Jeff Newmiller
2013-Jan-26 15:50 UTC
[R] Setting global variables inside R reference class ?
How can we possibly know where you went wrong if you don't tell us where you went? http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. Praveen K <pravinkenator at gmail.com> wrote:>Hello, > >I'm a newbie to R, I have a quesiton. > >I'm a bit confused on global variable assignments. > >I have the following situation. I have 2 global variables current_idx >and >previous_idx. *These 2 global variables have to be set by a method in a >reference class*. > >Essentially, using <<- assignment operator should work right ? But, I >get >this warning > >Non-local assignment to non-field names (possibly misspelled?) > >Where am I going wrong ? > >Will assign(current_idx, index, envir = .GlobalEnv) work ? > > >Thanks ! > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at 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.