Tutorials on object-oriented programming in R Are there good tutorials on object-oriented programming in R?
It would be great if it included the following:


*

*how to define a class;

*differences between S3 and S4 classes;

*operator overloading (I'd like to be able to write a+b where a and b are instances of the class I have in mind).

 A: In addition to @suncoolsu excellent response, there is A (Not So) Short Introduction to S4, by Christophe Genolini. It is available on CRAN website.
A: Hadley Wickham's "Advanced R" has some very good intro and references.
I am replicating this section for better indexing.

Picking a system
Three OO systems is a lot for one language, but for
most R programming, S3 suffices. In R you usually create fairly simple
objects and methods for pre-existing generic functions like print(),
summary(), and plot(). S3 is well suited to this task, and the
majority of OO code that I have written in R is S3. S3 is a little
quirky, but it gets the job done with a minimum of code.
If you are creating more complicated systems of interrelated objects,
S4 may be more appropriate. A good example is the Matrix package by
Douglas Bates and Martin Maechler. It is designed to efficiently store
and compute with many different types of sparse matrices. As of
version 1.1.3, it defines 102 classes and 20 generic functions. The
package is well written and well commented, and the accompanying
vignette (vignette("Intro2Matrix", package = "Matrix")) gives a good
overview of the structure of the package. S4 is also used extensively
by Bioconductor packages, which need to model complicated
interrelationships between biological objects. Bioconductor provides
many good resources for learning S4. If you’ve mastered S3, S4 is
relatively easy to pick up; the ideas are all the same, it is just
more formal, more strict, and more verbose.
If you’ve programmed in a mainstream OO language, RC will seem very
natural. But because they can introduce side effects through mutable
state, they are harder to understand. For example, when you usually
call f(a, b) in R you can assume that a and b will not be modified.
But if a and b are RC objects, they might be modified in the place.
Generally, when using RC objects you want to minimise side effects as
much as possible, and use them only where mutable states are
absolutely required. The majority of functions should still be
“functional”, and free of side effects. This makes code easier to
reason about and easier for other R programmers to understand.

He references "A practical tutorial on S4 programming".
There are a number of other interesting resources if you follow his pointers.
John M. Chambers says in "Object-Oriented Programming, Functional Programming and R":

R has also been strongly influenced by the ideas of functional
programming and, in particular, by the desire to combine functional
with object oriented programming

Would add something not directly related to the question but along the same idea: "DataFrames in Spark for Large Scale Data Science". Since this brings closer Scala and R, there might a great OO/functional synergy coming out of this.
A: Hadley Wickham's wiki on devtools is a great resource for the necessary information in a concise form. However, if you want an exhaustive resource, the R language manual's OOP section may be helpful. I am sure more experienced members will have better suggestions.
