December 2017
Beginner to intermediate
470 pages
12h 29m
English
The idea of an object is really just to bundle data and corresponding methods together. Lists in R are well-suited to implement this, since they can contain different data types, even functions, which are first class objects that can be assigned or returned like any other. In fact, we can literally create objects of a new class in R by taking a list and simply setting the class attribute of the list to a new value, which is how we create classes in S3.
Instead of providing definitions for S3 classes, we provide constructors. These constructors have the responsibility of creating objects (a string which has the parameter passed in the case of S3Color and a list in the case of S3Rectangle) and assigning ...