[R] Communicating from one function to another

2007-11-26 Thread Thomas L Jones, PhD
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 having to move it around in

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

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, perhaps in

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 should

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 global

Re: [R] Communicating from one function to another

2007-11-26 Thread Greg Snow
: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thomas L Jones, PhD Sent: Monday, November 26, 2007 10:11 AM To: R-project help Subject: [R] Communicating from one function to another My question is a seemingly simple one. I have a bunch of user-defined functions which compute

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

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