- How do you tell what OO system (S3 vs. S4) an object is associated with?To determine the OO system of an object, you use a process of elimination. If
!is.object(x), it’s a base object. If!isS4(x), it’s S3. If!is(x, "refClass"), it’s S4; otherwise it’s RC. - How do you determine the base type (like integer or list) of an object?
Usetypeof()to determine the base class of an object. - What is a generic function?
A generic function calls specific methods depending on the class of it inputs. In S3 and S4 object systems, methods belong to generic functions, not classes like in other programming languages. - What are the main differences between S3 and S4?
S4 is more formal than S3, and supports multiple inheritance and multiple dispatch. RC objects have reference semantics, and methods belong to classes, not functions.
Genetic Function with USArrest data set.
Plot(USArrest)
