Content deleted Content added
Added a code sample that applied the preceding suggestions for readability: using intermediate values, defining sub-tasks, and clearly labelling objects |
|||
Line 352:
=== Object-oriented programming ===
The R language has native support for [[object-oriented programming]]. There are two native [[Application framework|frameworks]], the so-called S3 and S4 systems. The former, being more informal, supports single dispatch on the first argument, and objects are assigned to a class
In the example below, <code>summary()</code> is a [[generic function]] that dispatches to different methods depending on whether its [[Argument of a function|argument]] is a numeric [[Vector (mathematics and physics)|vector]] or a
<syntaxhighlight lang="rout">
> data <- c("a", "b", "c", "a", NA)
|