Re: [R] scope of variables in R

2009-04-01 Thread Wacek Kusnierczyk
Stavros Macrakis wrote: > On Tue, Mar 31, 2009 at 3:41 PM, Wacek Kusnierczyk < > waclaw.marcin.kusnierc...@idi.ntnu.no> wrote: > > >> Stavros Macrakis wrote: >> >>> ...All that being said, programming with global variables makes certain >>> >> classes of bug much more likely >> >

Re: [R] scope of variables in R

2009-03-31 Thread Stavros Macrakis
On Tue, Mar 31, 2009 at 3:41 PM, Wacek Kusnierczyk < waclaw.marcin.kusnierc...@idi.ntnu.no> wrote: > Stavros Macrakis wrote: > > ...All that being said, programming with global variables makes certain > classes of bug much more likely > > ... in a language like r, that heavily relies on settin

Re: [R] scope of variables in R

2009-03-31 Thread Wacek Kusnierczyk
Wacek Kusnierczyk wrote: > > this is where multiple assignment might be your friend: > > source('http://miscell.googlecode.com/svn/rvalues/rvalues.r') > c(foo, bar, gee) := local({ > shared = 0 > foo = function() shared <<- 0 > bar = function(bar) shared <<- bar >

Re: [R] scope of variables in R

2009-03-31 Thread Wacek Kusnierczyk
Stavros Macrakis wrote: > On Tue, Mar 31, 2009 at 7:10 AM, wrote: > > >> I need to allocate (using C nomenclature) a set of "global" variables, some >> integer scalars and some double vectors. >> ... >> > > My question is: how can I have R interpreter allocate "global"variables > >> vis

Re: [R] scope of variables in R

2009-03-31 Thread Stavros Macrakis
On Tue, Mar 31, 2009 at 7:10 AM, wrote: > I need to allocate (using C nomenclature) a set of "global" variables, some > integer scalars and some double vectors. > ... My question is: how can I have R interpreter allocate "global"variables > visible and accessible by all the functions in the same

Re: [R] scope of variables in R

2009-03-31 Thread Sigbert Klinke
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, A) you should give and return the variables through input/output parameter of the functions, e.g. pwtset <- function(n, inout) { if (n < 100){ inout$ncof <- n } else { inout$ncof <- n -100 } ... return(inout) } ford <- function

[R] scope of variables in R

2009-03-31 Thread mauede
I need to allocate (using C nomenclature) a set of "global" variables, some integer scalars and some double vectors. I have placed the name of such variables in the file containing the main script and the called functions: # --