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

An S4 class is created using the setClass() function. At a minimum, the name of the Class and its attributes, formally known as slots in S4, must be specified. The slots are specified in with the representation() function, and a neat feature is that you specify the type expected for such attributes. This helps a bit with type-checking.

There are other features built-in that we are not going to look at here. For example, you could provide a function that verifies the object is consistent (has not been manipulated in some unexpected way). You can also specify default values, in a parameter called the prototype. If you want these features in S3, you can also implement them yourself, but they don't come ...

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