December 2017
Beginner to intermediate
470 pages
12h 29m
English
An S4 class is created using the setClass() function. At a minimum, the name of the Class and its attributes, formally known as slots in S4, must be specified. The slots are specified in with the representation() function, and a neat feature is that you specify the type expected for such attributes. This helps a bit with type-checking.
There are other features built-in that we are not going to look at here. For example, you could provide a function that verifies the object is consistent (has not been manipulated in some unexpected way). You can also specify default values, in a parameter called the prototype. If you want these features in S3, you can also implement them yourself, but they don't come ...