[R] Truly Global Variables

Lui ## lui.r.project at googlemail.com
Sat Jan 22 09:06:03 CET 2011

Hello everybody,

I have a problem that is bothering me for  quite a while now and I
don't know the answer... I want to create global variables (out of a
function) which I can access from all other functions... But somehow
that does not work too well. Attached some code for an example:

function_called <- function (){
	result = globalvariable*globalvariable

function_calls <- function(){


I would have assumed that I will get "100" printed on my screen, but
instead it said: "Fehler in function_called() : Objekt
'globalvariable' nicht gefunden", so the function "function_called"
did not have access to the variable "globalvariable".

I would be very thankful for some help... I want to implement it in
the genetic algorithms provided by the rgenoud package and dont know
any other way to have "changing" constraints (e.g. Portfolio
optimization and covariance matrix).
Thanks in advance! Any help greatly appreciated!


More information about the R-help mailing list