© Matt Wiley and Joshua F. Wiley 2020
M. Wiley, J. F. WileyAdvanced R 4 Data Programming and the Cloudhttps://doi.org/10.1007/978-1-4842-5973-3_5

5. Writing Classes and Methods

Matt Wiley1  and Joshua F. Wiley2
Victoria College, Victoria, TX, USA
Monash University, Melbourne, VIC, Australia

It is often helpful to have a function behave differently depending on the type of object passed. For example, when summarizing a variable, it makes sense to create a different summary for numeric or string data. It is possible to have a different function for every type of object, but then users would have to remember many function names, and to remain unique, function names may be longer. Object-oriented programming (OOP) is based on objects and is implemented ...

Get Advanced R 4 Data Programming and the Cloud: Using PostgreSQL, AWS, and Shiny now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.