Re: [R] Communicating from one function to another

2007-11-26 Thread hadley wickham
On 11/26/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Others have already answered your direct question but consider that > what you may want without realizing it is object-oriented programming. I agree with Gabor, you're not actually looking for a global state, but a mutable object (explic

Re: [R] Communicating from one function to another

2007-11-26 Thread Gabor Grothendieck
Others have already answered your direct question but consider that what you may want without realizing it is object-oriented programming. Here p is a proto object with components x and f. x is a variable and f is a method. The method f sets x to a. (Presumably in reality f would do other things

Re: [R] Communicating from one function to another

2007-11-26 Thread Greg Snow
Global variables are strongly discouraged in R, but there are sometimes when they may be needed and so are possible. One example where they are used is in random number generation, every time a random number function is called (rnorm for example) the "global" variable .Random.seed is updated so th

Re: [R] Communicating from one function to another

2007-11-26 Thread Duncan Murdoch
On 11/26/2007 1:46 PM, Alberto Monteiro wrote: > Duncan Murdoch wrote: >> >> R doesn't really have global variables. <<- goes looking in parent >> environments until it finds the target variable, and makes the >> assignment there. If it never finds one, it makes the assignment in >> the "glob

Re: [R] Communicating from one function to another

2007-11-26 Thread Alberto Monteiro
Duncan Murdoch wrote: > > R doesn't really have global variables. <<- goes looking in parent > environments until it finds the target variable, and makes the > assignment there. If it never finds one, it makes the assignment in > the "global environment", but the name is misleading: it shoul

Re: [R] Communicating from one function to another

2007-11-26 Thread Duncan Murdoch
On 11/26/2007 1:25 PM, Alberto Monteiro wrote: > Thomas L Jones wrote: >> >> My question is a seemingly simple one. I have a bunch of user- >> defined functions which compute such-and-such objects. I want to be >> able to define a variable in a particular function, then make use of >> it later, p

Re: [R] Communicating from one function to another

2007-11-26 Thread Alberto Monteiro
Thomas L Jones wrote: > > My question is a seemingly simple one. I have a bunch of user- > defined functions which compute such-and-such objects. I want to be > able to define a variable in a particular function, then make use of > it later, perhaps in a different function, without necessarily >