Now that you have a basic understanding of general object-oriented concepts, we will dig into R's own object models. There are two main sources of confusion when doing object-oriented programming in R. Before we start developing code, we will explain what these sources of confusion are. After we do, we will develop a small example to illustrate inheritance, composition, polymorphism, and encapsulation in R's S3, S4, and R6 object models. The same example will be used for all three models so that the reader can pinpoint precise differences. Specifically, we will model a Square inheriting from a Rectangle, which is in turn composed with a Color.
United States
Great Britain
India
Germany
France
Canada
Russia
Spain
Brazil
Australia
Singapore
Hungary
Philippines
Mexico
Thailand
Ukraine
Luxembourg
Estonia
Lithuania
Norway
Chile
South Korea
Ecuador
Colombia
Taiwan
Switzerland
Indonesia
Cyprus
Denmark
Finland
Poland
Malta
Czechia
New Zealand
Austria
Turkey
Sweden
Italy
Egypt
Belgium
Portugal
Slovenia
Ireland
Romania
Greece
Argentina
Malaysia
South Africa
Netherlands
Bulgaria
Latvia
Japan
Slovakia