♣6♣The Implementation of OO
R is an object oriented (OO) language but if you know how objects work in for example C++, it might take some mental flexibility to get your mind around how it works in R. R is not a compiled language, and it is build with versatility in mind. In some sense most objects are a to be considered as an object and can readily be extended without much formalism and without recompiling.1
Personally, I find it useful to think of R as a functional language with odd object possibilities. This means that if you want to make some simple analysis, then you might skip this section. We did our best to keep the knowledge of OO to a minimum for the whole book.
Programming languages that provide support for object oriented programming, allow code to be data-centric as opposed to functional languages that are in essence logic-oriented. They do that by introducing the concept of a “class.” A manifestation of that class then becomes the object that we can work with. Objects represent real life things. For example, if we want to create a software that manages bank accounts, it might be possible to have one object that is the account, another that is the customer, etc.
The main idea is that in other parts of the code we can work with the object “account” and ask that object for its balance. This has multiple advantages. First, of all, the logic of the way a balance is found is only in one place and in every call the same. Second, it becomes easier ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access