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

2007-04-03 Thread projection83
Thank you, I will give this a good think Mark Wardle wrote: > > projection83 wrote: >> My R code has got too complex to have a non-modular approach. Ive done >> some >> coding in other languages before, but I somehow cant figure out R's >> general >> rules for global and local variables. I hav

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

2007-04-03 Thread Mark Wardle
projection83 wrote: > My R code has got too complex to have a non-modular approach. Ive done some > coding in other languages before, but I somehow cant figure out R's general > rules for global and local variables. I have put a simple code below, if > anyone can show me what i need to add to make

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

2007-04-02 Thread jim holtman
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 obje

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

2007-04-02 Thread Alberto Monteiro
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 n

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

2007-04-01 Thread jim holtman
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. g_Means<-numeric() defineSamples<- function() { g_Means <<-5 # check out ?"<<-" } runit<-functio

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

2007-04-01 Thread projection83
My R code has got too complex to have a non-modular approach. Ive done some coding in other languages before, but I somehow cant figure out R's general rules for global and local variables. I have put a simple code below, if anyone can show me what i need to add to make this work, i would greatly