Generic Functions
Polymorphism in R can be obtained by the generics. It allows certain names to be treated as methods and they act as dispatchers. Let’s understand with the help of plot() function and summary function. In R programming the plot() and summary() functions return different results depending on the objects being passed to them and that’s why they are generic functions that implement polymorphism.
Polymorphism in R Programming
R language is evolving and it implements parametric polymorphism, which means that methods in R refer to functions, not classes. Parametric polymorphism primarily lets you define a generic method or function for types of objects you haven’t yet defined and may never do. This means that one can use the same name for several functions with different sets of arguments and from various classes. R’s method call mechanism is generics which allows registering certain names to be treated as methods in R, and they act as dispatchers.
Contact Us