How do you tell what object system (S3 vs. S4) an object is associated with?
To determine what system an object uses, you are able to use a process of elimination with these commands.
is.object(x) – will return true if the thing you are testing is an object.
isS4(object) – will return true if the object is an S4 object and false if it’s an S3 object.
is(object , “refClass”) – will return true if your object is a reference class.
> is(Inventory_520782772_2016.February.07truncated, “refClass”)
How do you determine the base type (like integer or list) of an object?
In order to determine what the base type of an object is, you can use the command typeof() and it’ll return the object type
What is a generic function?
A generic function determines what method to call from the input it’s given. A S3 generic can take one argument, but a S4 generic can take multiple arguments.
What are the main differences between S3 and S4?
S3 systems are used the vast majority of the time and are simpler, less formal systems. S4 systems are more complicated, adding more formality to the syntax. S4 has the ability to use method dispatch to pass multiple arguments to a generic function and supports multiple inheritance, allowing you to inherit characteristics from multiple classes.