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

Public methods and polymorphism

Since S4 also uses parametric polymorphism (methods belong to functions, not classes) and we have already explained it a couple of times before, we are going to just point out the differences with S3 at this point. First, instead of using the UseMethod() function to register methods with R, we use the setGeneric() function, with the name of the method, and a function that calls the standardGeneric() function inside. This will provide the dispatch mechanism for S4 objects.

To actually create a method, instead of using a naming convention as we do in S3, we actually pass the name of the class and the method to the setMethod() function, as well as the function that should be used as a method. Second, the order ...

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