Re: [R] (Newbie)Basic Basic global vs. local variables

From: jim holtman <>
Date: Mon 02 Apr 2007 - 20:21:41 GMT

As long as you know what you are doing, and watch out carefully, then you can do it. BTW, I do exactly what you are saying about manipulating large data objects. I will use the 'indices' in functions like 'lapply' and in the body of the function reference that data that is held in the global object. Very seldom, I will change data with the "<<-", but that is usually after I have exhausted some other approaches. Globals, and 'gotos' are a necessary evil, but I have learned how to write programs with goto's after a lot of effort.

On 4/2/07, Alberto Monteiro <> wrote:
> Jim Holtman wrote:
> >
> > The following will work, but I would suggest that you redesign your
> > functions so that they do not use 'globals'; It is not nice for
> functions
> > to have side-effects.
> >
> Globals are Evil, but, like goto, sometimes they can make a big
> program become simpler. I don't see a nice alternative to globals
> when I have a huge database where a lot of different functions
> read and write.
> But maybe this is ideology/religion/politics...
> Alberto Monteiro

Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

	[[alternative HTML version deleted]]

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Apr 03 06:25:55 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 02 Apr 2007 - 22:30:47 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.