Re: [R] Referring to objects themselves

2011-03-20 Thread Duncan Murdoch
On 11-03-19 10:21 PM, Kenn Konstabel wrote: On Sun, Mar 20, 2011 at 4:13 AM, Kenn Konstabellebats...@gmail.com wrote: you can omit the list and do the following: /.../ (but you don't really need this in this case as you can use balance instead of this$balance) P.S. using this would

Re: [R] Referring to objects themselves

2011-03-20 Thread Kenn Konstabel
On Sun, Mar 20, 2011 at 12:43 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 11-03-19 10:21 PM, Kenn Konstabel wrote: On Sun, Mar 20, 2011 at 4:13 AM, Kenn Konstabellebats...@gmail.com wrote: you can omit the list and do the following: /.../ (but you don't really need this in

[R] Referring to objects themselves

2011-03-19 Thread Russ Abbott
Is it possible to refer to an object from within a method, as in *this *in Java? I can't find anything about this in the documentation. Sorry if I missed it. Thanks. *-- Russ Abbott* *_* *** Professor, Computer Science* * California State

Re: [R] Referring to objects themselves

2011-03-19 Thread Gabor Grothendieck
On Sat, Mar 19, 2011 at 6:34 PM, Russ Abbott russ.abb...@gmail.com wrote: Is it possible to refer to an object from within a method, as in *this *in Java?  I can't find anything about this in the documentation.  Sorry if I missed it. Assuming you are referring to S3, the first argument to a

Re: [R] Referring to objects themselves

2011-03-19 Thread Russ Abbott
Actually, I guess I'm not really talking about objects. I was looking through the scoping demo. It uses this function. open.account - function(total) { + + list( +deposit = function(amount) { +if(amount = 0) +stop(Deposits must be positive!\n) +

Re: [R] Referring to objects themselves

2011-03-19 Thread Janko Thyson
, 19. März 2011 23:35 An: r-help@r-project.org Betreff: [R] Referring to objects themselves Is it possible to refer to an object from within a method, as in *this *in Java? I can't find anything about this in the documentation. Sorry if I missed it. Thanks. *-- Russ Abbott

Re: [R] Referring to objects themselves

2011-03-19 Thread Gabor Grothendieck
On Sat, Mar 19, 2011 at 8:02 PM, Russ Abbott russ.abb...@gmail.com wrote: Actually, I guess I'm not really talking about objects. I was looking through the scoping demo. It uses this function. open.account - function(total) { + +     list( +        deposit = function(amount) { +        

Re: [R] Referring to objects themselves

2011-03-19 Thread Kenn Konstabel
You could (in addition to the other suggestions) try package proto (. refers to self but see also the package's vignette) account - proto( deposit = function(., amount) { if(amount = 0) stop(Deposits must be positive!\n) .$total - .$total + amount

Re: [R] Referring to objects themselves

2011-03-19 Thread Bert Gunter
-Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Russ Abbott Gesendet: Samstag, 19. März 2011 23:35 An: r-help@r-project.org Betreff: [R] Referring to objects themselves Is it possible to refer to an object from within a method

Re: [R] Referring to objects themselves

2011-03-19 Thread Russ Abbott
: [R] Referring to objects themselves Is it possible to refer to an object from within a method, as in *this *in Java? I can't find anything about this in the documentation. Sorry if I missed it. Thanks. *-- Russ Abbott

Re: [R] Referring to objects themselves

2011-03-19 Thread Kenn Konstabel
that way. HTH, Janko -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] Im Auftrag von Russ Abbott Gesendet: Samstag, 19. März 2011 23:35 An: r-help@r-project.org Betreff: [R] Referring to objects themselves

Re: [R] Referring to objects themselves

2011-03-19 Thread Kenn Konstabel
On Sun, Mar 20, 2011 at 4:13 AM, Kenn Konstabel lebats...@gmail.com wrote: you can omit the list and do the following: /.../ (but you don't really need this in this case as you can use balance instead of this$balance) P.S. using this would make some difference in one case: instead of

Re: [R] Referring to objects themselves

2011-03-19 Thread Russ Abbott
Wonderful! Thanks. I think I've got it. You can even put this - environment() at the top as long as this is returned at the end. I gather that the environment keeps accumulating elements even though it is assigned to 'this' at the beginning. I had thought that $ worked only on lists,

Re: [R] Referring to objects themselves

2011-03-19 Thread Gabor Grothendieck
On Sat, Mar 19, 2011 at 9:45 PM, Russ Abbott russ.abb...@gmail.com wrote: Thanks for all the suggestions. I realize that this isn't the most important thing in the world -- and as a newcomer to R I gather it's not the way most people use R anyway. But I tried to do what looked like the

Re: [R] Referring to objects themselves

2011-03-19 Thread Henrik Bengtsson
-Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Russ Abbott Gesendet: Samstag, 19. März 2011 23:35 An: r-help@r-project.org Betreff: [R] Referring to objects themselves Is it possible to refer to an object from

Re: [R] Referring to objects themselves

2011-03-19 Thread Russ Abbott
Abbott Gesendet: Samstag, 19. März 2011 23:35 An: r-help@r-project.org Betreff: [R] Referring to objects themselves Is it possible to refer to an object from within a method, as in *this *in Java? I can't find anything about this in the documentation. Sorry if I missed

Re: [R] Referring to objects themselves

2011-03-19 Thread Gabor Grothendieck
On Sun, Mar 20, 2011 at 12:10 AM, Russ Abbott russ.abb...@gmail.com wrote: Actually I'm a big Haskell fan. So I think of functional programming very positively.  However, the environment() function doesn't seem to be treated functionally.  If I write    this - environment() at the top of the