Content deleted Content added
→Native pipe operator: This is an encyclopedia, not your personal blog. Tags: Reverted 2017 wikitext editor |
ClueBot NG (talk | contribs) m Reverting possible vandalism by 154.115.204.4 to version by 207.91.254.122. Report False Positive? Thanks, ClueBot NG. (4413697) (Bot) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 29:
| file_ext = {{Unbulleted list|.r<ref>{{Cite web|title=R scripts|url=http://mercury.webster.edu/aleshunas/R_learning_infrastructure/R%20scripts.html|access-date=2021-07-17|website=mercury.webster.edu}}</ref>|.rdata|.rhistory|.rds|.rda<ref>{{Cite web|date=2017-06-09|title=R Data Format Family (.rdata, .rda)|url=https://www.loc.gov/preservation/digital/formats/fdd/fdd000470.shtml|access-date=2021-07-17|website=Loc.gov}}</ref>}}
}}
{{redirect-distinguish|R lang|Erlang}}
'''R''' is a [[programming language]] for [[statistical computing]] and [[Data and information visualization|data visualization]]. It has been widely adopted in the fields of [[data mining]], [[bioinformatics]], [[data analysis]], and [[data science]].<ref>{{Cite journal
Line 57 ⟶ 58:
== History ==
{{Multiple image |total_width = 250 | align = left
|
| caption1 = [[Ross Ihaka]]
| caption2 = [[Robert Gentleman (statistician)|Robert Gentleman]]
▲|File:Ross Ihaka (5189180796).jpg
▲|File:Robert Gentleman on R Consortium.jpg
}}
R was started by professors [[Ross Ihaka]] and [[Robert Gentleman (statistician)|Robert Gentleman]] as a programming language to teach introductory statistics at the [[University of Auckland]].<ref name="otago_pg12">{{Cite web
|last=Ihaka
Line 319 ⟶ 314:
</syntaxhighlight>
An alternative to nested functions is the use of intermediate objects, rather than the pipe operator:
<syntaxhighlight lang="rout">
> mtcars_subset_rows <- subset(mtcars, cyl == 4)
> num_mtcars_subset <- nrow(mtcars_subset_rows)
> print(num_mtcars_subset)
[1] 11
</syntaxhighlight>While the pipe operator can produce code that is easier to read, influential R programmers like [[Hadley Wickham]] suggest to chain together at most 10-15 lines of code using this operator and saving them into objects having meaningful names to avoid [[Code obfuscating|code obfuscation]].<ref>{{Cite book |last=Wickham |first=Hadley |url=https://r4ds.hadley.nz/ |title=R for data science: import, tidy, transform, visualize, and model data |last2=Çetinkaya-Rundel |first2=Mine |last3=Grolemund |first3=Garrett |date=2023 |publisher=O'Reilly |isbn=978-1-4920-9740-2 |edition=2nd |___location=Beijing; Sebastopol, CA |chapter=4 Workflow: code style |oclc=on1390607935 |chapter-url=https://r4ds.hadley.nz/workflow-style.html}}</ref>
=== 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 simply by setting a "class" attribute in each object. The latter is a system like the [[CLOS|Common Lisp Object System (CLOS)]], with formal classes (also derived from [[S (programming language)#S4|S]]) and generic methods, which 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>
|