As I'm often confronted with situations where S4 programming is needed to keep an overview, I've collected quite some sources on S4 objects, methods and programming. I've listed them here as a reference. Please add your own sources as well.
On the web
methods
help files : help files from the package methods, where much of the necessary information can be foundBooks
PS : if somebody finds the community checkbox, you can make this a community-owned post. Somehow I can't find it in the edit window any more...
Overview. The S4 system in R is a system for object oriented programing. Confusingly, R has support for at least 3 different systems for object oriented programming: S3, S4 and S5 (also known as reference classes).
The S3 and S4 software in R are two generations implementing functional object-oriented programming. S3 is the original, simpler for initial programming but less general, less formal and less open to validation. The S4 formal methods and classes provide these features but require more programming.
There are 6 types of objects in R Programming. They include vector, list, matrix, array, factor, and data frame. Vectors are one of the basic R programming data objects. They are six types of atomic vectors- logical, integer, character, raw, double, and complex.
Everything in R is an object. An object is simply a data structure that has some methods and attributes. A class is just a blueprint or a sketch of these objects. It represents the set of properties or methods that are common to all objects of one type.
My write up of S4 (still in progress) is available here: http://adv-r.had.co.nz/S4.html
R for programmers (Matloff) (free) and Introduction to scientific programming and simulation (Jones) have a short section on "new-style" S4 classes.
Another good book by John Chambers: "Programming with Data: A Guide to the S Language". As the name suggests it is actually about S, not R, but it provides a lot of valuable information about S4 classes anyway.
There's also some information in the R manuals "Writing R Extensions" and "R Internals" (particularly the latter). Those can be found at http://cran.r-project.org/doc/manuals/.
Finally, I would recommend "How S4 Methods Work", which is a great overview of how to think about S4 as it fits into R.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With