[R] S3 vs. S4

Marc Schwartz MSchwartz at mn.rr.com
Sun Jan 1 21:59:49 CET 2006


On Sun, 2006-01-01 at 13:07 -0600, Erin Hodgess wrote:
> Dear R People: 
> 
> Could someone direct me to some documentation on the
> difference between S3 and S4 classes, please?
> 
> For example, why would a person use one as opposed to another?
> Maybe pros and cons of each?
> 
> Thanks in advance!
> 
> R Version 2.2.0 (I'm downloading the new one this afternoon!) Windows.
> 
> Happy New Year!


Some places to start:

1. Fritz Leisch's "S4 Classes and Methods" from the useR! 2004 meeting:

   http://www.ci.tuwien.ac.at/Conferences/useR-2004/Keynotes/Leisch.pdf


2. Doug Bates' "Converting Packages to S4" in R News 3/1, 2003:

   http://cran.r-project.org/doc/Rnews/Rnews_2003-1.pdf


3. Thomas Lumley's "Programmer's Niche: A Simple Class, in S3 and S4"
   in R News 4/1, 2004:

   http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf




Also, if you do a Google search with the following:

  http://www.google.com/search?q=site:stat.ethz.ch+s3+s4

that will bring up some discussions (248 hits) in the list archives,
mainly in r-devel, some of which will be relevant to your question.



In addition, you might want to look at:

1. John M. Chambers. Programming with Data. Springer, New York, 1998.
   ISBN 0-387-98503-4.  AKA "The Green Book"


2. William N. Venables and Brian D. Ripley. S Programming. Springer,
   2000. ISBN 0-387-98966-8.


HTH,

Marc Schwartz




More information about the R-help mailing list