
Object-Oriented Programming in R 107
3.4.10 Replacement methods
Replacement functions were discussed in Section 2.7, and S3 replacement
functions were discussed in Section 3.3.6. S4 replacement methods are quite
similar. They require that an appropriate S4 generic function be defined;
usually its name is of the form genfun<-. You must ensure that the method
returns the whole object and that the last argument is named value. This
ensures that R can always identify the value that is going to be assigned.
We continue the example given above and define a method that will change
the value in the slot named a. We first define an appropriate generic function
and ...