[R] S3 vs. S4

Gabor Grothendieck ggrothendieck at gmail.com
Sun Jan 1 22:06:58 CET 2006


On 1/1/06, Erin Hodgess <hodgess at gator.dt.uh.edu> wrote:
> Dear R People:
>
> Could someone direct me to some documentation on the
> difference between S3 and S4 classes, please?

Check out:

http://www.maths.lth.se/help/R/S3toS4/

and references there.


>
> For example, why would a person use one as opposed to another?
> Maybe pros and cons of each?
>

S3 is simpler (but still quite powerful) and can have higher
performance. S4 has more functionality including multiple
inheritance and type checking of arguments.

stats4 in the R distribution is an example of an S4 package.
You could also look at the its package which is an S4 package
for irregular time series and zoo which is an S3 package for
the same purpose (although they differ in a number of ways
even apart from the different oo infrastructures).

Bioconductor is a large set of packages that use S4.

> Thanks in advance!
>
> R Version 2.2.0 (I'm downloading the new one this afternoon!) Windows.
>
> Happy New Year!
>
>
> Sincerely,
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: hodgess at gator.uhd.edu




More information about the R-help mailing list