Skip to Content
R Programming By Example
book

R Programming By Example

by Omar Trejo Navarro
December 2017
Beginner to intermediate
470 pages
12h 29m
English
Packt Publishing
Content preview from R Programming By Example

Classes, constructors, and composition

Classes in R6 are created with the R6Class() function, and we pass the name of the class and lists of public and private objects. These objects can be either attributes or methods. As you can see, building a class definition in R6 produces much cleaner code, which is put together in a single definition instead of the step-by-step process used in S3 and S4. This approach is more like what you can find in other popular languages.

You may specify how the constructor should behave by using the initialize method. This specific method will be called when an instance of the class is created.

There are two important differences between our names in the following definition and what we used for the S3 and S4 ...

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.
Start your free trial

You might also like

Efficient R Programming

Efficient R Programming

Colin Gillespie, Robin Lovelace
R Programming

R Programming

Jared P. Lander

Publisher Resources

ISBN: 9781788292542Supplemental Content