Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
R (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== 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 by just setting a "class" attribute in each object. The latter is a [[CLOS|Common Lisp Object System (CLOS)-like system]] of formal classes (also derived from [[S (programming language)#S4|S]]) and generic methods that supports [[multiple dispatch]] and [[multiple inheritance]]<ref>{{cite web|url=https://stat.ethz.ch/R-manual/R-devel/library/base/html/UseMethod.html|title=Class Methods|access-date=2024-04-25}}</ref> In the example, <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 "factor": <syntaxhighlight lang="rout"> > data <- c("a", "b", "c", "a", NA) > summary(data) Length Class Mode 5 character character > summary(as.factor(data)) a b c NA's 2 1 1 1 </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)