Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-10 Thread daniel schnaider
It is excellent. thanks! On Sun, Nov 10, 2013 at 12:49 PM, Martin Morgan wrote: > On 11/09/2013 11:31 PM, Hadley Wickham wrote: > >> Modelling a mutable entity, i.e. an account, is really a perfect >> example of when to use reference classes. You might find the examples >> on http://adv-r.had.

Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-10 Thread daniel schnaider
Thanks Martin. It worked well. Two new questions related to the same subject. 1) Why create this semantic of a final argument name specifically names value? 2) Regarding performance. When CustomerID(ac) <- "54321" runs, does it only change the slot from whatever it was to 54321, or it really creat

Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-10 Thread Martin Morgan
On 11/09/2013 11:31 PM, Hadley Wickham wrote: Modelling a mutable entity, i.e. an account, is really a perfect example of when to use reference classes. You might find the examples on http://adv-r.had.co.nz/OO-essentials.html give you a better feel for the strengths and weaknesses of R's differe

Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-10 Thread Martin Morgan
On 11/10/2013 03:54 AM, daniel schnaider wrote: Thanks Martin. It worked well. Two new questions related to the same subject. 1) Why create this semantic of a final argument name specifically names value? I do not know. It is a requirement of replacement methods in R in general, not just S4 m

Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-09 Thread Hadley Wickham
Modelling a mutable entity, i.e. an account, is really a perfect example of when to use reference classes. You might find the examples on http://adv-r.had.co.nz/OO-essentials.html give you a better feel for the strengths and weaknesses of R's different OO systems. Hadley On Sat, Nov 9, 2013 at 9

Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-09 Thread Martin Morgan
On 11/09/2013 06:31 AM, daniel schnaider wrote: It is my first time programming with S4 and I can't get the setter fuction to actually change the value of the slot created by the constructor. I guess it has to do with local copy, global copy, etc. of the variable - but, I could't find anything r

Re: [R] S4; Setter function is not chaning slot value as expected

2013-11-09 Thread Simon Zehnder
If you want to set a slot you have to refer to it: ac@CustomerID <- “54321” or you use your setter: ac <- CustomerID(ac, “54321”) What you did was creating a new symbol CustomerID referring to the String “54321” CustomerID <- “54321” CustomerID [1] “54321” Best Simon On 09 Nov 2013, at 15:

[R] S4; Setter function is not chaning slot value as expected

2013-11-09 Thread daniel schnaider
It is my first time programming with S4 and I can't get the setter fuction to actually change the value of the slot created by the constructor. I guess it has to do with local copy, global copy, etc. of the variable - but, I could't find anything relevant in documentation. Tried to copy examples