1. Learn
  2. /
  3. Courses
  4. /
  5. Object-Oriented Programming with S3 and R6 in R

Exercise

You've Already Been Working With Objects

In the Introduction to R course you already met several common R objects such as numeric, logical and character vectors, as well as data.frames. One of the principles of OOP is that functions can behave differently for different kinds of object.

The summary() function is a good example of this. Since different types of variable need to be summarized in different ways, the output that is displayed to you varies depending upon what you pass into it.

Instructions

100 XP
  • Run the code provided in the editor to create several objects of different types.
  • Call summary() on each of these objects (one at a time), then examine the output and try to understand it.