Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 198
6.3. S4 Objects
ОглавлениеThe S4 system is very similar to the S3 system, but it adds a certain obligatory formalism. For example, it is necessary to define the class before using it. This adds some lines of code but the payoff is increased clarity.
In S4
1 classes have formal definitions that describe their data fields and inheritance structures (parent classes);
2 method dispatch is more flexible and can be based on multiple arguments to a generic function, not just one; and
3 there is a special operator, @, for extracting fields from an S4 object.
All the S4 related code is stored in the methods package.