R (programming language): Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
imported>OAbot
m Open access bot: url-access updated in citation with #oabot.
 
imported>ScalarFactor
Reverting edit(s) by 2603:9009:801:B8E:995C:7A84:871B:8867 (talk) to rev. 1295643263 by Pac Veten: Non-constructive edit (UV 0.1.6)
Line 1: Line 1:
{{Technical|introduction|date=May 2025}}
{{Short description|Programming language for statistics}}
{{Short description|Programming language for statistics}}
{{About|the programming language|the eighteenth letter of the English alphabet|R|other uses|R (disambiguation)}}
{{About|the programming language|the eighteenth letter of the English alphabet|R|other uses|R (disambiguation)}}
Line 9: Line 8:
| screenshot = R terminal.jpg
| screenshot = R terminal.jpg
| screenshot_size = 250px
| screenshot_size = 250px
| screenshot caption = R terminal
| screenshot caption = Terminal window for R
| released = {{Start date and age|1993|08}}
| released = {{Start date and age|1993|08}}
| designer = [[Ross Ihaka]] and [[Robert Gentleman (statistician)|Robert Gentleman]]
| designer = [[Ross Ihaka]] and [[Robert Gentleman (statistician)|Robert Gentleman]]
Line 32: Line 31:
}}
}}


'''R''' is a [[programming language]] for [[statistical computing]] and [[Data and information visualization|data visualization]]. It has been adopted in the [[Academic discipline|fields]] of [[data mining]], [[bioinformatics]] and [[data analysis]]/[[data science]].<ref>{{Cite journal
'''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
   |last1=Giorgi
   |last1=Giorgi
   |first1=Federico M.
   |first1=Federico M.
Line 52: Line 51:
   |doi-access=free }}</ref>
   |doi-access=free }}</ref>


The core ''R'' language is augmented by a large number of [[R package|extension software packages]], which contain [[Reusability|reusable code]], documentation, and sample data.
The core R language is extended by a large number of [[R package|software packages]], which contain [[Reusability|reusable code]], documentation, and sample data. Some of the most popular R packages are in the [[tidyverse]] collection, which enhances functionality for visualizing, transforming, and modelling data, as well as improves the ease of programming (according to the authors and users).<ref>{{Cite web |title=Home - RDocumentation |url=https://www.rdocumentation.org/ |access-date=2025-06-13 |website=www.rdocumentation.org}}</ref>


''R'' software is [[Open source|open-source]] and [[free software]]. R is a [[GNU Project]] and licensed under the [[GNU General Public License]].<ref name="gnugpl">{{Cite web |title=R - Free Software Directory |url=https://directory.fsf.org/wiki/R#tab=Details |access-date=2024-01-26 |website=directory.fsf.org}}</ref><ref>{{Cite web |title=R: What is R? |url=https://www.r-project.org/about.html |access-date=2025-05-10 |website=www.r-project.org}}</ref> It is written primarily in [[C (programming language)|C]], [[Fortran]], and [[Self-hosting (compilers)|R itself]]. [[Preprocessor|Precompiled]] [[executable]]s are provided for various [[operating system]]s.
R is [[free and open-source software]] distributed under the [[GNU General Public License]].<ref name="gnugpl">{{Cite web |title=R - Free Software Directory |url=https://directory.fsf.org/wiki/R#tab=Details |access-date=2024-01-26 |website=directory.fsf.org}}</ref><ref>{{Cite web |title=R: What is R? |url=https://www.r-project.org/about.html |access-date=2025-05-10 |website=www.r-project.org}}</ref> The language is implemented primarily in [[C (programming language)|C]], [[Fortran]], and [[Self-hosting (compilers)|R itself]]. [[Preprocessor|Precompiled]] [[executable]]s are available for the major [[operating system]]s (including [[Linux]], [[MacOS]], and [[Microsoft Windows]]).


As an [[interpreted language]], ''R'' has a native [[command line interface]]. Moreover, multiple [[Third-party software component|third-party]] [[graphical user interface]]s are available, such as [[RStudio]]—an [[integrated development environment]]—and [[Jupyter]]—a [[notebook interface]].
Its core is an [[interpreted language]] with a native [[command line interface]]. In addition, multiple [[Third-party software component|third-party]] applications are available as [[graphical user interface]]s; such applications include [[RStudio]] (an [[integrated development environment]]) and [[Jupyter]] (a [[notebook interface]]).


== History ==
== History ==
Line 72: Line 71:
}}
}}


''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
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
   |last=Ihaka
   |first=Ross
   |first=Ross
Line 82: Line 81:
   |archive-url=https://web.archive.org/web/20221228043824/https://www.stat.auckland.ac.nz/~ihaka/downloads/Otago.pdf  
   |archive-url=https://web.archive.org/web/20221228043824/https://www.stat.auckland.ac.nz/~ihaka/downloads/Otago.pdf  
   |archive-date=2022-12-28
   |archive-date=2022-12-28
   |access-date=2022-12-27}}</ref> The language was inspired by the [[S (programming language)|S programming language]], with most S programs able to run unaltered in ''R''.<ref name="R FAQ"/> The language was also inspired by [[Scheme (programming language)|Scheme's]] [[lexical scoping]], allowing for [[local variable]]s.<ref name="Morandat"/>
   |access-date=2022-12-27}}</ref> The language was inspired by the [[S (programming language)|S programming language]], with most S programs able to run unaltered in R.<ref name="R FAQ"/> The language was also inspired by [[Scheme (programming language)|Scheme's]] [[lexical scoping]], allowing for [[local variable]]s.<ref name="Morandat"/>


The name of the language, ''R'', comes from being both an S language successor as well as the shared first letter of the authors, Ross and Robert.<ref>{{Cite web
The name of the language, R, comes from being both an S language successor and the shared first letter of the authors, Ross and Robert.<ref>{{Cite web
   |last1=Hornik
   |last1=Hornik
   |first1=Kurt
   |first1=Kurt
Line 96: Line 95:
   |access-date=2022-12-28
   |access-date=2022-12-28
   |website=[[R package#Comprehensive R Archive Network (CRAN)|The Comprehensive R Archive Network]]
   |website=[[R package#Comprehensive R Archive Network (CRAN)|The Comprehensive R Archive Network]]
   |at=2.13 What is the R Foundation?}}</ref> In August 1993, Ihaka and Gentleman posted a [[Binary file|binary]] of ''R'' on StatLib — a data archive [[website]].<ref>{{Cite web |title=Index of /datasets |url=https://lib.stat.cmu.edu/datasets/ |access-date=2024-09-05 |website=lib.stat.cmu.edu}}</ref> At the same time, they announced the posting on the ''s-news'' [[mailing list]].<ref name="Interface98">{{Cite web
   |at=2.13 What is the R Foundation?}}</ref> In August 1993, Ihaka and Gentleman posted a [[Binary file|binary]] file of R on StatLib — a data archive website.<ref>{{Cite web |title=Index of /datasets |url=https://lib.stat.cmu.edu/datasets/ |access-date=2024-09-05 |website=lib.stat.cmu.edu}}</ref> At the same time, they announced the posting on the ''s-news'' mailing list.<ref name="Interface98">{{Cite web
   |last=Ihaka
   |last=Ihaka
   |first=Ross
   |first=Ross
Line 105: Line 104:
   |archive-url=https://web.archive.org/web/20221228071311/https://www.stat.auckland.ac.nz/~ihaka/downloads/Interface98.pdf  
   |archive-url=https://web.archive.org/web/20221228071311/https://www.stat.auckland.ac.nz/~ihaka/downloads/Interface98.pdf  
   |archive-date=2022-12-28
   |archive-date=2022-12-28
   |access-date=2022-12-28}}</ref> On 5 December 1997, ''R'' became a [[GNU project]] when version 0.60 was released.<ref>{{Cite web
   |access-date=2022-12-28}}</ref> On 5 December 1997, R became a [[GNU project]] when version 0.60 was released.<ref>{{Cite web
   |last=Ihaka
   |last=Ihaka
   |first=Ross
   |first=Ross
Line 129: Line 128:
{{Main|R package}}
{{Main|R package}}


[[File:Ggplot2 PlantGrowth violin plot.svg|alt=refer to caption|thumb|[[Violin plot]] created from the R visualization package [[ggplot2]]]]
[[File:Ggplot2 PlantGrowth violin plot.svg|alt=refer to caption|thumb|A [[violin plot]] created with the R package [[ggplot2]] for data visualization ]]
[[R package]]s are collections of functions, documentation, and data that expand R.<ref name="rds_pagexvii">{{cite book
[[R package]]s are collections of functions, documentation, and data that expand R.<ref name="rds_pagexvii">{{cite book
   | last1 = Wickham
   | last1 = Wickham
Line 142: Line 141:
   | page = xvii
   | page = xvii
   | isbn = 978-1-492-09740-2
   | isbn = 978-1-492-09740-2
}}</ref> For example, packages can add reporting features (using packages like [[RStudio#Reproducible analyses with R Markdown vignettes|RMarkdown]], Quarto,<ref>{{Cite web |title=Quarto |url=https://quarto.org/ |access-date=2024-09-05 |website=Quarto |language=en}}</ref> [[knitr]], and [[Sweave]]) and the capability to implement various statistical techniques (such as [[linear]], [[generalized linear model|generalized linear]] and [[Nonlinear system|nonlinear]] modeling, classical [[Statistical hypothesis testing|statistical tests]], [[spatial analysis|spatial]] analysis, [[time-series analysis]], and [[Cluster analysis|clustering]]). Perceived easy package installation and usability have contributed to the language's adoption in [[data science]].<ref name="Chambers2020">{{Cite journal
}}</ref> For example, packages can add reporting features (using packages such as [[RStudio#Reproducible analyses with R Markdown vignettes|RMarkdown]], Quarto,<ref>{{Cite web |title=Quarto |url=https://quarto.org/ |access-date=2024-09-05 |website=Quarto |language=en}}</ref> [[knitr]], and [[Sweave]]) and support for various statistical techniques (such as [[linear]], [[generalized linear model|generalized linear]] and [[Nonlinear system|nonlinear]] modeling, classical [[Statistical hypothesis testing|statistical tests]], [[spatial analysis|spatial]] analysis, [[time-series analysis]], and [[Cluster analysis|clustering]]). Ease of package installation and use have contributed to the language's adoption in [[data science]].<ref name="Chambers2020">{{Cite journal
   |last=Chambers
   |last=Chambers
   |first=John M.
   |first=John M.
Line 158: Line 157:
   |quote=The R language and related software play a major role in computing for data science. ... R packages provide tools for a wide range of purposes and users.}}</ref>
   |quote=The R language and related software play a major role in computing for data science. ... R packages provide tools for a wide range of purposes and users.}}</ref>


Immediately available when starting R, base packages provide the basic and necessary syntax and commands for programming, computing, graphics production, [[Elementary arithmetic|basic arithmetic]], and statistical functionality.<ref>{{cite book|title=The Book of R: A First Course in Programming and Statistics|first1=Tilman M.|last1=Davies|isbn=9781593276515|year=2016|publisher=No Starch Press|location=San Francisco, California|chapter=Installing R and Contributed Packages|pages=739}}</ref>
Immediately available when starting R after installation, base packages provide the fundamental and necessary syntax and commands for programming, computing, graphics production, [[Elementary arithmetic|basic arithmetic]], and statistical functionality.<ref>{{cite book|title=The Book of R: A First Course in Programming and Statistics|first1=Tilman M.|last1=Davies|isbn=9781593276515|year=2016|publisher=No Starch Press|location=San Francisco, California|chapter=Installing R and Contributed Packages|pages=739}}</ref>


An example R package is the [[tidyverse]] package, which bundles several subsidiary packages to provide a [[User experience|common interface]]. It specializes in tasks related to accessing and processing "[[tidy data]]",<ref>[[Hadley Wickham|Wickham, Hadley]] (2014). "Tidy Data" ([https://vita.had.co.nz/papers/tidy-data.pdf PDF]). ''Journal of Statistical Software''. '''59''' (10). [[Doi (identifier)|doi]]:10.18637/jss.v059.i10.</ref> which are data contained in a [[Two-dimensional space|two-dimensional]] table with a single row for each [[observation]] and a single column for each variable.<ref name="rds">{{cite book |last1=Wickham |first1=Hadley |title=R for Data Science, Second Edition |last2=Cetinkaya-Rundel |first2=Mine |last3=Grolemund |first3=Garrett |publisher=[[O'Reilly Media|O'Reilly]] |year=2023 |isbn=978-1-492-09740-2}}</ref>
An example is the [[tidyverse]] collection of R packages, which bundles several subsidiary packages to provide a common [[API]]. The collection specializes in tasks related to accessing and processing "[[tidy data]]",<ref>[[Hadley Wickham|Wickham, Hadley]] (2014). "Tidy Data" ([https://vita.had.co.nz/papers/tidy-data.pdf PDF]). ''Journal of Statistical Software''. '''59''' (10). [[Doi (identifier)|doi]]:10.18637/jss.v059.i10.</ref> which are data contained in a [[Two-dimensional space|two-dimensional]] table with a single row for each [[observation]] and a single column for each variable.<ref name="rds">{{cite book |last1=Wickham |first1=Hadley |title=R for Data Science, Second Edition |last2=Cetinkaya-Rundel |first2=Mine |last3=Grolemund |first3=Garrett |publisher=[[O'Reilly Media|O'Reilly]] |year=2023 |isbn=978-1-492-09740-2}}</ref>


Installing a package occurs only once. For example, to install the ''tidyverse'' package:<ref name="rds" />
Installing a package occurs only once. For example, to install the tidyverse collection:<ref name="rds" />
<syntaxhighlight lang="rout">
<syntaxhighlight lang="rout">
> install.packages("tidyverse")
> install.packages("tidyverse")
</syntaxhighlight>
</syntaxhighlight>


To load the functions, data, and documentation of a package, one executes the <code>library()</code> function. To load ''tidyverse'':{{efn|This displays to [[Standard streams|standard error]] a listing of all the packages that ''tidyverse'' depends upon. It may also display warnings showing namespace conflicts, which may typically be ignored.}}
To load the functions, data, and documentation of a package, one calls the <code>library()</code> function. To load the tidyverse collection, one can execute the following code:{{efn|This code displays to [[Standard streams|standard error]] a listing of all the packages that the tidyverse collection depends upon. The code may also display warnings showing namespace conflicts, which may typically be ignored.}}
<syntaxhighlight lang="rout">
<syntaxhighlight lang="rout">
> # Package name can be enclosed in quotes
> # The package name can be enclosed in quotes
> library("tidyverse")
> library("tidyverse")


> # But also the package name can be called without quotes
> # But the package name can also be used without quotes
> library(tidyverse)
> library(tidyverse)
</syntaxhighlight>
</syntaxhighlight>


The [[R package#Comprehensive R Archive Network (CRAN)|Comprehensive R Archive Network]] (CRAN) was founded in 1997 by Kurt Hornik and [[Friedrich Leisch]] to host R's [[source code]], executable files, documentation, and user-created packages.<ref name=":10" /> Its name and scope mimic the [[Comprehensive TeX Archive Network]] (CTAN) and the [[Comprehensive Perl Archive Network]] (CPAN).<ref name=":10">{{Cite journal |last=Hornik |first=Kurt |date=2012 |title=The Comprehensive R Archive Network |url=https://onlinelibrary.wiley.com/doi/10.1002/wics.1212 |journal=WIREs Computational Statistics |language=en |volume=4 |issue=4 |pages=394–398 |doi=10.1002/wics.1212 |issn=1939-5108 |s2cid=62231320|url-access=subscription }}</ref> CRAN originally had three [[Mirror site|mirroring sites]] and twelve contributed packages.<ref>{{cite Q|Q101068595}}<!-- Announce: CRAN -->.</ref> {{As of|2024|10|16}}, it has 99 mirrors<ref name=":3">{{Cite web |title=The Status of CRAN Mirrors |url=https://cran.r-project.org/mirmon_report.html |access-date=2024-10-16 |website=cran.r-project.org}}</ref> and 21,513 contributed packages.<ref name=":9">{{Cite web |title=CRAN - Contributed Packages |url=https://cran.r-project.org/web/packages/index.html |access-date=2024-10-16 |website=cran.r-project.org}}</ref> Packages are also available on [[Repository (version control)|repositories]] like R-Forge, Omegahat, and [[GitHub]].<ref>{{Cite web |title=R-Forge: Welcome |url=https://r-forge.r-project.org/ |access-date=2024-09-05 |website=r-forge.r-project.org}}</ref><ref>{{Cite web |title=The Omega Project for Statistical Computing |url=https://www.omegahat.net/ |access-date=2024-09-05 |website=www.omegahat.net}}</ref><ref>{{Cite web |title=Build software better, together |url=https://github.com/trending/r |access-date=2024-09-05 |website=GitHub |language=en}}</ref>
The [[R package#Comprehensive R Archive Network (CRAN)|Comprehensive R Archive Network]] (CRAN) was founded in 1997 by Kurt Hornik and [[Friedrich Leisch]] to host R's [[source code]], executable files, documentation, and user-created packages.<ref name=":10" /> CRAN's name and scope mimic the [[Comprehensive TeX Archive Network]] (CTAN) and the [[Comprehensive Perl Archive Network]] (CPAN).<ref name=":10">{{Cite journal |last=Hornik |first=Kurt |date=2012 |title=The Comprehensive R Archive Network |url=https://onlinelibrary.wiley.com/doi/10.1002/wics.1212 |journal=WIREs Computational Statistics |language=en |volume=4 |issue=4 |pages=394–398 |doi=10.1002/wics.1212 |issn=1939-5108 |s2cid=62231320|url-access=subscription }}</ref> CRAN originally had only three [[Mirror site|mirror sites]] and twelve contributed packages.<ref>{{cite Q|Q101068595}}<!-- Announce: CRAN -->.</ref> {{As of|2024|10|16}}, it has 99 mirrors<ref name=":3">{{Cite web |title=The Status of CRAN Mirrors |url=https://cran.r-project.org/mirmon_report.html |access-date=2024-10-16 |website=cran.r-project.org}}</ref> and 21,513 contributed packages.<ref name=":9">{{Cite web |title=CRAN - Contributed Packages |url=https://cran.r-project.org/web/packages/index.html |access-date=2024-10-16 |website=cran.r-project.org}}</ref> Packages are also available in [[Repository (version control)|repositories]] such as R-Forge, Omegahat, and [[GitHub]].<ref>{{Cite web |title=R-Forge: Welcome |url=https://r-forge.r-project.org/ |access-date=2024-09-05 |website=r-forge.r-project.org}}</ref><ref>{{Cite web |title=The Omega Project for Statistical Computing |url=https://www.omegahat.net/ |access-date=2024-09-05 |website=www.omegahat.net}}</ref><ref>{{Cite web |title=Build software better, together |url=https://github.com/trending/r |access-date=2024-09-05 |website=GitHub |language=en}}</ref>


On the CRAN web site as a form of guidance, [https://cran.r-project.org/web/views/ Task Views] lists packages on CRAN that are relevant for tasks related to a certain topics, such as [[causal inference]], [[finance]], [[genetics]], [[high-performance computing]], [[machine learning]], [[medical imaging]], [[meta-analysis]], [[social science]]s, and [[spatial statistics]].
To provide guidance on the CRAN web site, its [https://cran.r-project.org/web/views/ Task Views] area lists packages that are relevant for specific topics; sample topics include [[causal inference]], [[finance]], [[genetics]], [[high-performance computing]], [[machine learning]], [[medical imaging]], [[meta-analysis]], [[social science]]s, and [[spatial statistics]].


The [[Bioconductor]] project provides packages for [[Genomics|genomic]] data analysis, [[complementary DNA]], [[microarray]], and [[high-throughput sequencing]] methods.
The [[Bioconductor]] project provides packages for [[Genomics|genomic]] data analysis, [[complementary DNA]], [[microarray]], and [[high-throughput sequencing]] methods.
Line 185: Line 184:
There are three main groups that help support R software development:
There are three main groups that help support R software development:


* The R Core Team was founded in 1997 to maintain the ''R'' [[source code]].
* The R Core Team was founded in 1997 to maintain the R [[source code]].
* The R Foundation for Statistical Computing was founded in April 2003 to provide financial support.
* The R Foundation for Statistical Computing was founded in April 2003 to provide financial support.
* The R Consortium is a [[Linux Foundation]] project to develop ''R'' infrastructure.
* The R Consortium is a [[Linux Foundation]] project to develop R infrastructure.


''[[The R Journal]]'' is an [[open access]], [[academic journal]] which features short to medium-length articles on the use and development of R. It includes articles on packages, programming tips, CRAN news, and foundation news.
''[[The R Journal]]'' is an [[open access]], [[academic journal]] that features short to medium-length articles on the use and development of R. The journal includes articles on packages, programming tips, CRAN news, and foundation news.


The R community hosts many conferences and in-person meetups.{{efn|See here for a community maintained GitHub list {{URL|jumpingrivers.github.io/meetingsR/}}}} These groups include:
The R community hosts many conferences and in-person meetups.{{efn|Information about conferences and meetings is available in a community-maintained list on GitHub, {{URL|jumpingrivers.github.io/meetingsR/}}}} These groups include:


* UseR!: an annual international R user conference ([https://www.r-project.org/conferences/ website])
* UseR!: an annual international R user conference ([https://www.r-project.org/conferences/ website])
Line 199: Line 198:
* R Conference ([https://rstats.ai/ website])
* R Conference ([https://rstats.ai/ website])
* posit::conf (formerly known as rstudio::conf) ([https://www.posit.co/conference/ website])
* posit::conf (formerly known as rstudio::conf) ([https://www.posit.co/conference/ website])
On social media sites like Twitter, the hashtag <code>#rstats</code> can be used to keep up with new developments in the R community.<ref>{{Cite book |last=Wickham |first=Hadley |url=https://r4ds.had.co.nz/introduction.html |title=1 Introduction {{!}} R for Data Science |last2=Grolemund |first2=Garrett |date=January 2017 |publisher=[[O'Reilly Media]] |year=2017 |isbn=978-1491910399 |edition=1st |language=en}}</ref>
On social media sites such as Twitter, the hashtag <code>#rstats</code> can be used to follow new developments in the R community.<ref>{{Cite book |last=Wickham |first=Hadley |url=https://r4ds.had.co.nz/introduction.html |title=1 Introduction {{!}} R for Data Science |last2=Grolemund |first2=Garrett |date=January 2017 |publisher=[[O'Reilly Media]] |year=2017 |isbn=978-1491910399 |edition=1st |language=en}}</ref>


== Examples ==
== Examples ==
=== Hello, World! ===
=== Hello, World! ===
[["Hello, World!" program]]:
The following is a [["Hello, World!" program]]:
<syntaxhighlight lang="rout">> print("Hello, World!")
<syntaxhighlight lang="rout">> print("Hello, World!")
[1] "Hello, World!"</syntaxhighlight>Alternatively:<syntaxhighlight lang="rout">
[1] "Hello, World!"</syntaxhighlight>Here is an alternative version, which uses the <code>cat()</code> function:<syntaxhighlight lang="rout">
> cat("Hello, World!")
> cat("Hello, World!")
Hello, World!
Hello, World!
Line 211: Line 210:


=== Basic syntax ===
=== Basic syntax ===
The following examples illustrate the basic [[programming language syntax|syntax of the language]] and use of the command-line interface.{{efn|An expanded list of standard language features can be found in the R manual, "An Introduction to R" {{URL|cran.r-project.org/doc/manuals/R-intro.pdf}}}}
The following examples illustrate the basic [[programming language syntax|syntax of the language]] and use of the command-line interface.{{efn|An expanded list of standard language features can be found in the manual "An Introduction to R", {{URL|cran.r-project.org/doc/manuals/R-intro.pdf}}}}


In R, the generally preferred [[Assignment (computer science)|assignment operator]] is an arrow made from two characters <code><-</code>, although <code>=</code> can be used in some cases.<ref>{{cite web|author=R Development Core Team|title=Assignments with the = Operator|url=https://developer.r-project.org/equalAssign.html|access-date=2018-09-11}}</ref>
In R, the generally preferred [[Assignment (computer science)|assignment operator]] is an arrow made from two characters <code><-</code>, although <code>=</code> can be used in some cases.<ref>{{cite web|author=R Development Core Team|title=Assignments with the = Operator|url=https://developer.r-project.org/equalAssign.html|access-date=2018-09-11}}</ref>
Line 217: Line 216:
<syntaxhighlight lang="rout">
<syntaxhighlight lang="rout">
> x <- 1:6 # Create a numeric vector in the current environment
> x <- 1:6 # Create a numeric vector in the current environment
> y <- x^2 # Create vector based on the values in x.
> y <- x^2 # Similarly, create a vector based on the values in x.
> print(y) # Print the vector’s contents.
> print(y) # Print the vector’s contents.
[1]  1  4  9 16 25 36
[1]  1  4  9 16 25 36
Line 225: Line 224:
[1]  2  6 12 20 30 42
[1]  2  6 12 20 30 42


> z_matrix <- matrix(z, nrow = 3) # Create a new matrix that turns the vector z into a 3x2 matrix object
> z_matrix <- matrix(z, nrow = 3) # Create a new matrix that transforms the vector z into a 3x2 matrix object
> z_matrix  
> z_matrix  
     [,1] [,2]
     [,1] [,2]
Line 232: Line 231:
[3,]  12  42
[3,]  12  42


> 2 * t(z_matrix) - 2 # Transpose the matrix, multiply every element by 2, subtract 2 from each element in the matrix, and return the results to the terminal.
> 2 * t(z_matrix) - 2 # Transpose the matrix; multiply every element by 2; subtract 2 from each element in the matrix; and then return the results to the terminal.
     [,1] [,2] [,3]
     [,1] [,2] [,3]
[1,]    2  10  22
[1,]    2  10  22
[2,]  38  58  82
[2,]  38  58  82


> new_df <- data.frame(t(z_matrix), row.names = c("A", "B")) # Create a new data.frame object that contains the data from a transposed z_matrix, with row names 'A' and 'B'
> new_df <- data.frame(t(z_matrix), row.names = c("A", "B")) # Create a new dataframe object that contains the data from a transposed z_matrix, with row names 'A' and 'B'
> names(new_df) <- c("X", "Y", "Z") # Set the column names of new_df as X, Y, and Z.
> names(new_df) <- c("X", "Y", "Z") # Set the column names of the new_df dataframe as X, Y, and Z.
> print(new_df)  # Print the current results.
> print(new_df)  # Print the current results.
   X  Y  Z
   X  Y  Z
Line 247: Line 246:
[1] 12 42
[1] 12 42


> new_df$Z == new_df['Z'] && new_df[3] == new_df$Z # The data.frame column Z can be accessed using $Z, ['Z'], or [3] syntax and the values are the same.  
> new_df$Z == new_df['Z'] && new_df[3] == new_df$Z # The dataframe column Z can be accessed using the syntax $Z, ['Z'], or [3], and the values are the same.  
[1] TRUE
[1] TRUE


> attributes(new_df) # Print attributes information about the new_df object
> attributes(new_df) # Print information about attributes of the new_df dataframe
$names
$names
[1] "X" "Y" "Z"
[1] "X" "Y" "Z"
Line 260: Line 259:
[1] "data.frame"
[1] "data.frame"


> attributes(new_df)$row.names <- c("one", "two") # Access and then change the row.names attribute; can also be done using rownames()
> attributes(new_df)$row.names <- c("one", "two") # Access and then change the row.names attribute; this can also be done using the rownames() function
> new_df
> new_df
     X  Y  Z
     X  Y  Z
Line 268: Line 267:
</syntaxhighlight>
</syntaxhighlight>
=== Structure of a function ===
=== Structure of a function ===
R is able to create [[Function (computer programming)|functions]] to add new functionality for reuse.<ref>{{cite web|url=http://www.statmethods.net/management/userfunctions.html|title=Quick-R: User-Defined Functions|first=Robert|last=Kabacoff|year=2012|access-date=2018-09-28|website=statmethods.net}}</ref> [[Object (computer science)|Objects]] created within the body of the function (which are enclosed by curly brackets) remain [[Local variable|only accessible]] from within the function, and any [[data type]] may be returned. In R, almost all functions and all [[user-defined function]]s are [[closure (computer programming)|closures]].<ref>{{cite web|url=http://adv-r.had.co.nz/Functional-programming.html#closures|title=Advanced R - Functional programming - Closures|website=adv-r.had.co.nz|first=Hadley|last=Wickham}}</ref>
R is able to create [[Function (computer programming)|functions]] that add new functionality for code reuse.<ref>{{cite web|url=http://www.statmethods.net/management/userfunctions.html|title=Quick-R: User-Defined Functions|first=Robert|last=Kabacoff|year=2012|access-date=2018-09-28|website=statmethods.net}}</ref> [[Object (computer science)|Objects]] created within the body of the function (which are enclosed by curly brackets) remain [[Local variable|accessible only]] from within the function, and any [[data type]] may be returned. In R, almost all functions and all [[user-defined function]]s are [[closure (computer programming)|closures]].<ref>{{cite web|url=http://adv-r.had.co.nz/Functional-programming.html#closures|title=Advanced R - Functional programming - Closures|website=adv-r.had.co.nz|first=Hadley|last=Wickham}}</ref>


Example of creating a function to perform some arithmetic calculation:
The following is an example of creating a function to perform an arithmetic calculation:
<syntaxhighlight lang="r"># The input parameters are x and y.
<syntaxhighlight lang="r"># The function's input parameters are x and y.
# The function, being named f, returns a linear combination of x and y.
# The function, named f, returns a linear combination of x and y.
f <- function(x, y) {
f <- function(x, y) {
   z <- 3 * x + 4 * y
   z <- 3 * x + 4 * y


   # An explicit return() statement is optional, could be replaced with simply `z`.
   # An explicit return() statement is optional--it could be replaced with simply `z` in this case.
   return(z)
   return(z)
}
}


# Alternatively, the last statement executed is implicitly returned.
# As an alternative, the last statement executed in a function is returned implicitly.
f <- function(x, y) 3 * x + 4 * y</syntaxhighlight>
f <- function(x, y) 3 * x + 4 * y</syntaxhighlight>


Usage output:
The following is some output from using the function defined above:
<syntaxhighlight lang="rout">
<syntaxhighlight lang="rout">
> f(1, 2) #  3 * 1 + 4 * 2 = 3 + 8
> f(1, 2) #  3 * 1 + 4 * 2 = 3 + 8
Line 295: Line 294:
</syntaxhighlight>
</syntaxhighlight>


It is possible to define functions to be used as [[Infix notation|infix operators]] with the special syntax <code>`%name%`</code> where "name" is the function variable name:
It is possible to define functions to be used as [[Infix notation|infix operators]] by using the special syntax <code>`%name%`</code>, where "name" is the function variable name:
<syntaxhighlight lang="rout">
<syntaxhighlight lang="rout">
> `%sumx2y2%` <- function(e1, e2) {e1 ^ 2 + e2 ^ 2}
> `%sumx2y2%` <- function(e1, e2) {e1 ^ 2 + e2 ^ 2}
Line 302: Line 301:
</syntaxhighlight>
</syntaxhighlight>


Since version 4.1.0 functions can be written in a short notation, which is useful for passing anonymous functions to higher-order functions:<ref>{{cite web|url=https://cran.r-project.org/doc/manuals/r-release/NEWS.html#:~:text=R%20now%20provides%20a%20shorthand%20notation%20for%20creating%20functions|title=NEWS|website=r-project.org}}</ref>  
Since R version 4.1.0, functions can be written in a short notation, which is useful for passing anonymous functions to higher-order functions:<ref>{{cite web|url=https://cran.r-project.org/doc/manuals/r-release/NEWS.html#:~:text=R%20now%20provides%20a%20shorthand%20notation%20for%20creating%20functions|title=NEWS|website=r-project.org}}</ref>  
<syntaxhighlight lang="rout">
<syntaxhighlight lang="rout">
> sapply(1:5, \(i) i^2)    # here \(i) is the same as function(i)  
> sapply(1:5, \(i) i^2)    # here \(i) is the same as function(i)  
Line 309: Line 308:


=== Native pipe operator ===
=== Native pipe operator ===
In R version 4.1.0, a native [[Pipeline (computing)|pipe operator]], <code>|></code>, was introduced.<ref>{{Cite web |title=R: R News |url=https://cran.r-project.org/doc/manuals/r-devel/NEWS.html |access-date=2024-03-14 |website=cran.r-project.org}}</ref> This operator allows users to chain functions together one after another, instead of a nested function call.
In R version 4.1.0, a native [[Pipeline (computing)|pipe operator]], <code>|></code>, was introduced.<ref>{{Cite web |title=R: R News |url=https://cran.r-project.org/doc/manuals/r-devel/NEWS.html |access-date=2024-03-14 |website=cran.r-project.org}}</ref> This operator allows users to chain functions together, rather than using nested function calls.


<syntaxhighlight lang="rout">
<syntaxhighlight lang="rout">
Line 319: Line 318:
</syntaxhighlight>
</syntaxhighlight>


Another alternative to nested functions, in contrast to using the pipe character, is using intermediate objects:
Another alternative to nested functions is the use of intermediate objects, rather than the pipe operator:


<syntaxhighlight lang="rout">
<syntaxhighlight lang="rout">
Line 326: Line 325:
> print(num_mtcars_subset)
> print(num_mtcars_subset)
[1] 11
[1] 11
</syntaxhighlight>While the pipe operator can produce code that is easier to read, it has been advised to pipe together at most 10 to 15 lines and chunk code into [[Task (project management)|sub-tasks]] which are saved into objects with meaningful names.<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>  
</syntaxhighlight>While the pipe operator can produce code that is easier to read, it is advisable to chain together at most 10-15 lines of code using this operator, as well as to chunk code into [[Task (project management)|sub-tasks]] that are saved into objects having meaningful names.<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>  


Here is an example with fewer than 10 lines that some readers may still struggle to grasp without intermediate named steps:<syntaxhighlight lang="r" line="1">(\(x, n = 42, key = c(letters, LETTERS, " ", ":", ")"))
The following is an example having fewer than 10 lines, which some readers may find difficult to grasp in the absence of intermediate named steps:<syntaxhighlight lang="r" line="1">(\(x, n = 42, key = c(letters, LETTERS, " ", ":", ")"))
     strsplit(x, "")[[1]] |>
     strsplit(x, "")[[1]] |>
     (Vectorize(\(chr) which(chr == key) - 1))() |>
     (Vectorize(\(chr) which(chr == key) - 1))() |>
Line 335: Line 334:
     (\(i) key[i + 1])() |>
     (\(i) key[i + 1])() |>
     paste(collapse = "")
     paste(collapse = "")
)("duvFkvFksnvEyLkHAErnqnoyr")</syntaxhighlight>
)("duvFkvFksnvEyLkHAErnqnoyr")</syntaxhighlight>The following is a version of the preceding code that is easier to read:<syntaxhighlight lang="r">
default_key <- c(letters, LETTERS, " ", ":", ")")
 
f <- function(x, n = 42, key = default_key) {
    split_input <- strsplit(x, "")[[1]]
    results <- (Vectorize(\(chr) which(chr == key) - 1))(split_input) |>
        (`+`)(n) |>
        (`%%`)(length(key)) |>
        (\(i) key[i + 1])()
    combined_results <- paste(results, collapse = "")
    return(combined_results)
}
 
f("duvFkvFksnvEyLkHAErnqnoyr")
</syntaxhighlight>


=== Object-oriented programming ===
=== 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>
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>


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":
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 ''factor'':
<syntaxhighlight lang="rout">
<syntaxhighlight lang="rout">
> data <- c("a", "b", "c", "a", NA)
> data <- c("a", "b", "c", "a", NA)
Line 352: Line 365:


=== Modeling and plotting ===
=== Modeling and plotting ===
[[File:Plots from lm example.svg|right|thumb|200px|Diagnostic plots from plotting "model" (q.v. "plot.lm()" function). Notice the mathematical notation allowed in labels (lower left plot).]]
[[File:Plots from lm example.svg|right|thumb|200px|Diagnostic plots for the model from the example code in the "Modeling and plotting" section (q.v. the <code>plot.lm()</code> function). Mathematical notation is allowed in labels, as shown in the lower left plot.]]
The R language has built-in support for [[data modeling]] and graphics. The following example shows how R can generate and plot a [[linear model]] with residuals.
The R language has built-in support for [[data modeling]] and graphics. The following example shows how R can generate and plot a [[linear model]] with residuals.
<syntaxhighlight lang="r">
<syntaxhighlight lang="r">
Line 359: Line 372:
y <- x^2
y <- x^2


# Linear regression model y = A + B * x
# Linear regression model: y = A + B * x
model <- lm(y ~ x)
model <- lm(y ~ x)


Line 365: Line 378:
summary(model)
summary(model)


# Create a 2 by 2 layout for figures
# Create a 2-by-2 layout for figures
par(mfrow = c(2, 2))
par(mfrow = c(2, 2))


Line 372: Line 385:
</syntaxhighlight>
</syntaxhighlight>


Output:
The output from the <code>summary()</code> function in the preceding code block is as follows:
<syntaxhighlight lang="rout">
<syntaxhighlight lang="rout">
Residuals:
Residuals:
Line 391: Line 404:


=== Mandelbrot set ===
=== Mandelbrot set ===
[[File:Mandelbrot Creation Animation.gif|thumb|200px|"Mandelbrot.gif" graphic created in R. (Note: Colors differ from actual output.)]]
[[File:Mandelbrot Creation Animation.gif|thumb|200px|A Mandelbrot set as visualized in R. (Note: The colours in this image differ from the output of the sample code in the "Mandelbrot set" section.)]]
This [[Mandelbrot set]] example highlights the use of [[complex numbers]]. It models the first 20 [[iteration]]s of the [[equation]] <code>z = z<sup>2</sup> + c</code>, where <code>c</code> represents different [[Complex number|complex constants]].
This example of a [[Mandelbrot set]] highlights the use of [[complex numbers]]. It models the first 20 [[iteration]]s of the [[equation]] <code>z = z<sup>2</sup> + c</code>, where <code>c</code> represents different [[Complex number|complex constants]].


Install the package that provides the <code>write.gif()</code> function beforehand:
To run this sample code, it is necessary to first install the package that provides the <code>write.gif()</code> function:
<syntaxhighlight lang="r">
<syntaxhighlight lang="r">
install.packages("caTools")
install.packages("caTools")
</syntaxhighlight>
</syntaxhighlight>


R Source code:
The sample code is as follows:
<syntaxhighlight lang="r">
<syntaxhighlight lang="r">library(caTools)
library(caTools)


jet.colors <-
jet.colors <-
Line 439: Line 451:
     "Mandelbrot.gif",
     "Mandelbrot.gif",
     col = jet.colors,
     col = jet.colors,
     delay = 100)
     delay = 100)</syntaxhighlight>
</syntaxhighlight>


== Version names ==
== Version names ==
[[File:CD of R 1 0 0.png|alt=A CD with autographs on it|thumb|CD of R Version 1.0.0, autographed by the core team of R, photographed R in Quebec City in 2019|180x180px]]
[[File:CD of R 1 0 0.png|alt=A CD with autographs on it|thumb|A CD of R Version 1.0.0, autographed by the core team of R, photographed in Quebec City in 2019|180x180px]]
All R version releases from 2.14.0 onward have [[Code name|codenames]] that make reference to [[Peanuts]] comics and films.<ref>{{Cite book |last=Monkman |first=Martin |url=https://bookdown.org/martin_monkman/DataScienceResources_book/r-release-names.html |title=Chapter 5 R Release Names {{!}} Data Science with R: A Resource Compendium}}</ref><ref>{{Cite web |last=McGowan |first=Lucy D’Agostino |date=2017-09-28 |title=R release names |url=https://livefreeordichotomize.com/posts/2017-09-28-r-release-names/index.html |access-date=2024-04-07 |website=livefreeordichotomize.com |language=en}}</ref><ref>{{Citation |title=r-hub/rversions |date=2024-02-29 |url=https://github.com/r-hub/rversions |access-date=2024-04-07 |publisher=The R-hub project of the R Consortium}}</ref>
All R version releases from 2.14.0 onward have [[Code name|codenames]] that make reference to [[Peanuts]] comics and films.<ref>{{Cite book |last=Monkman |first=Martin |url=https://bookdown.org/martin_monkman/DataScienceResources_book/r-release-names.html |title=Chapter 5 R Release Names {{!}} Data Science with R: A Resource Compendium}}</ref><ref>{{Cite web |last=McGowan |first=Lucy D’Agostino |date=2017-09-28 |title=R release names |url=https://livefreeordichotomize.com/posts/2017-09-28-r-release-names/index.html |access-date=2024-04-07 |website=livefreeordichotomize.com |language=en}}</ref><ref>{{Citation |title=r-hub/rversions |date=2024-02-29 |url=https://github.com/r-hub/rversions |access-date=2024-04-07 |publisher=The R-hub project of the R Consortium}}</ref>


In 2018, core R developer [[Peter Dalgaard]] presented a history of R releases since 1997.<ref name=":2">{{Cite web |last=Dalgaard |first=Peter |date=2018-07-15 |title=What's in a name? 20 years of R release management |url=https://www.youtube.com/watch?v=z1vTSdRolgI |access-date=2024-04-09 |website=[[YouTube]] |format=video}}</ref> Some notable early releases before the named releases include:
In 2018, core R developer [[Peter Dalgaard]] presented a history of R releases since 1997.<ref name=":2">{{Cite web |last=Dalgaard |first=Peter |date=2018-07-15 |title=What's in a name? 20 years of R release management |url=https://www.youtube.com/watch?v=z1vTSdRolgI |access-date=2024-04-09 |website=[[YouTube]] |format=video}}</ref> Some notable early releases before the named releases include the following:


* Version 1.0.0 released on 29 February 2000 (2000-02-29), a [[Leap days|leap day]]
* Version 1.0.0, released on 29 February 2000, a [[Leap days|leap day]]
* Version 2.0.0 released on 4 October 2004 (2004-10-04), "which at least had a nice ring to it"<ref name=":2" />
* Version 2.0.0, released on 4 October 2004, "which at least had a nice ring to it"<ref name=":2" />


The idea of naming R version releases was inspired by the [[Debian version history|Debian]] and [[Ubuntu version history|Ubuntu]] version naming system. Dalgaard also noted that another reason for the use of Peanuts references for R codenames is because, "everyone in statistics is a [[P-value|P-nut]]".<ref name=":2" />
The idea of naming R version releases was inspired by the naming system for [[Debian version history|Debian]] and [[Ubuntu version history|Ubuntu]] versions. Dalgaard noted an additional reason for the use of Peanuts references in R codenames—the humorous observation that "everyone in statistics is a [[P-value|P-nut]]."<ref name=":2" />


{| class="wikitable"
{| class="wikitable"
Line 460: Line 471:
!Peanuts reference
!Peanuts reference
!Reference
!Reference
|-
|4.5.1
|2025-06-13
|Great Square Root
|<ref>{{Cite web |title=Read Peanuts by Charles Schulz on GoComics |url=https://www.gocomics.com/peanuts/1978/02/24 |access-date=2025-06-13 |website=www.gocomics.com |language=en}}</ref>
|<ref>{{Cite web |title=[Rd] R 4.5.1 is released |url=https://hypatia.math.ethz.ch/pipermail/r-announce/2025/000713.html |access-date=2025-06-13 |website=hypatia.math.ethz.ch}}</ref>
|-
|-
|4.5.0
|4.5.0
Line 835: Line 852:


== Interfaces ==
== Interfaces ==
R comes installed with a [[Command-line interface|command line console]], but it is not the only way to interface with R.
{{Gallery
|title=Examples of user interfaces for R
|width=160 | height=150 |noborder=yes
|align=center
|footer=
|File:RKWard_screenshot.png
|Screenshot of the RKWard front-end running on the KDE 4 environment
|alt1=
|File:RinEmacswithESS.png
|R running in the emacs editor with the ESS package
|alt2=
|File:RStudio 2023.12.1 Build 402 (256-135).png
|[[RStudio]] [[integrated development environment]] (IDE)
|mode=packed}}
 
R is installed with a [[Command-line interface|command line console]] by default, but there are multiple ways to interface with the language:


* By [[Integrated development environment|integrated development environment (IDE)]]:
* [[Integrated development environment|Integrated development environment (IDE)]]:
** R.app<ref>{{Cite web |title=R for macOS |url=https://cran.r-project.org/bin/macosx/ |access-date=2024-09-05 |website=cran.r-project.org}}</ref> (OSX/[[macOS]] only)
** R.app<ref>{{Cite web |title=R for macOS |url=https://cran.r-project.org/bin/macosx/ |access-date=2024-09-05 |website=cran.r-project.org}}</ref> (OSX/[[macOS]] only)
** [[Rattle GUI]]
** [[Rattle GUI]]
Line 844: Line 876:
** [[RStudio]]
** [[RStudio]]
** Tinn-R<ref>{{Cite web |title=IDE/Editor para Linguagem R {{!}} Tinn-R - Home |url=https://tinn-r.org/en/ |access-date=2024-09-05 |website=Tinn-R |language=pt-br}}</ref>
** Tinn-R<ref>{{Cite web |title=IDE/Editor para Linguagem R {{!}} Tinn-R - Home |url=https://tinn-r.org/en/ |access-date=2024-09-05 |website=Tinn-R |language=pt-br}}</ref>
* By general purpose IDEs:
* General-purpose IDEs:
** [[Eclipse (software)|Eclipse]] via the [https://marketplace.eclipse.org/content/statet-r/ StatET plugin]
** [[Eclipse (software)|Eclipse]] via the [https://marketplace.eclipse.org/content/statet-r/ StatET plugin]
** [[Microsoft Visual Studio|Visual Studio]] via [[R Tools for Visual Studio]].
** [[Microsoft Visual Studio|Visual Studio]] via [[R Tools for Visual Studio]].
* By [[Source-code editor|source-code editors]]:
* [[Source-code editor|Source-code editors]]:
** [[Emacs Speaks Statistics|Emacs]]
** [[Emacs Speaks Statistics|Emacs]]
** [[Vim (text editor)|Vim]] via the [https://www.vim.org/scripts/script.php?script_id=2628 Nvim-R plugin]
** [[Vim (text editor)|Vim]] via the [https://www.vim.org/scripts/script.php?script_id=2628 Nvim-R plugin]
Line 854: Line 886:
** [[WinEdt]] ([https://cran.r-project.org/package=RWinEdt website])
** [[WinEdt]] ([https://cran.r-project.org/package=RWinEdt website])
** [[Jupyter]] ([https://docs.anaconda.com/anaconda/navigator/tutorials/r-lang/ website])
** [[Jupyter]] ([https://docs.anaconda.com/anaconda/navigator/tutorials/r-lang/ website])
* By other [[scripting language]]s:
* Other [[scripting language]]s:
** [[Python (programming language)|Python]] ([https://rpy2.github.io website])
** [[Python (programming language)|Python]] ([https://rpy2.github.io website])
** [[Perl]] ([https://metacpan.org/module/Statistics::R website])
** [[Perl]] ([https://metacpan.org/module/Statistics::R website])
Line 860: Line 892:
** [[F Sharp (programming language)|F#]] ([https://bluemountaincapital.github.io/FSharpRProvider/ website])
** [[F Sharp (programming language)|F#]] ([https://bluemountaincapital.github.io/FSharpRProvider/ website])
** [[Julia (programming language)|Julia]] ([https://github.com/JuliaInterop/RCall.jl source code]).
** [[Julia (programming language)|Julia]] ([https://github.com/JuliaInterop/RCall.jl source code]).
* By general purpose programming languages:
* General-purpose programming languages:
** [[Java (programming language)|Java]] via the [https://cran.r-project.org/web/packages/Rserve/index.html Rserve socket server]
** [[Java (programming language)|Java]] via the [https://cran.r-project.org/web/packages/Rserve/index.html Rserve socket server]
** [[C Sharp (programming language)|.NET C#]] ([https://rdotnet.github.io/rdotnet/ website])
** [[C Sharp (programming language)|.NET C#]] ([https://rdotnet.github.io/rdotnet/ website])


Statistical frameworks which use R in the background include [[Jamovi]] and [[JASP]].{{fact|date=March 2025}}
Statistical frameworks that use R in the background include [[Jamovi]] and [[JASP]].{{fact|date=March 2025}}


== Implementations ==
== Implementations ==
The main R implementation is written primarily in [[C (programming language)|C]], [[Fortran]], and [[Self-hosting (compilers)|R itself]]. Other implementations include:
The main R implementation is written primarily in [[C (programming language)|C]], [[Fortran]], and [[Self-hosting (compilers)|R itself]]. Other implementations include the following:
* [http://www.pqr-project.org pretty quick R] (pqR), by [[Radford M. Neal]], attempts to improve [[memory management]].
* [http://www.pqr-project.org pretty quick R] (pqR), by [[Radford M. Neal]], which attempts to improve [[memory management]].
* [[Renjin]] is an implementation of ''R'' for the [[Java virtual machine|Java Virtual Machine]].
* [[Renjin]] for the [[Java virtual machine|Java Virtual Machine]].
* [https://www.cs.kent.ac.uk/projects/cxxr CXXR] and Riposte<ref>{{cite book
* [https://www.cs.kent.ac.uk/projects/cxxr CXXR] and Riposte<ref>{{cite book
   |last1=Talbot
   |last1=Talbot
Line 884: Line 916:
   |publisher=ACM
   |publisher=ACM
   |isbn=9781450311823
   |isbn=9781450311823
   |s2cid=1989369}}</ref> are implementations of ''R'' written in [[C++]].
   |s2cid=1989369}}</ref> written in [[C++]].
* [[Oracle Corporation|Oracle's]] [https://github.com/oracle/fastr FastR] is an implementation of ''R'', built on [https://www.graalvm.org/ GraalVM].
* [[Oracle Corporation|Oracle's]] [https://github.com/oracle/fastr FastR] built on [https://www.graalvm.org/ GraalVM].
* [[TIBCO Software]], creator of [[S-PLUS]], wrote TERR — an ''R'' implementation to integrate with [[Spotfire]].<ref>Jackson, Joab (16 May 2013). [http://www.pcworld.com/article/2038944/tibco-offers-free-r-to-the-enterprise.html TIBCO offers free R to the enterprise]. ''PC World''. Retrieved 20 July 2015.</ref>
* [[TIBCO Software|TIBCO]] Enterprise Runtime for R (TERR) to integrate with [[Spotfire]].<ref>Jackson, Joab (16 May 2013). [http://www.pcworld.com/article/2038944/tibco-offers-free-r-to-the-enterprise.html TIBCO offers free R to the enterprise]. ''PC World''. Retrieved 20 July 2015.</ref> (The company also created [[S-PLUS|S-Plus]], an implementation of the S language.)


Microsoft R Open (MRO) was an ''R'' implementation. As of 30 June 2021, Microsoft started to phase out MRO in favor of the CRAN distribution.<ref>{{cite web
Microsoft R Open (MRO) was an R implementation. As of 30 June 2021, Microsoft began to phase out MRO in favor of the CRAN distribution.<ref>{{cite web
   |title=Looking to the future for R in Azure SQL and SQL Server
   |title=Looking to the future for R in Azure SQL and SQL Server
   |date=30 June 2021
   |date=30 June 2021
Line 898: Line 930:


Although R is an [[open-source]] project, some companies provide commercial support:
Although R is an [[open-source]] project, some companies provide commercial support:
* [[Oracle Corporation|Oracle]] provides commercial support for the ''[[Oracle Big Data Appliance|Big Data Appliance]]'', which integrates R into its other products.
* [[Oracle Corporation|Oracle]] provides commercial support for its [[Oracle Big Data Appliance|Big Data Appliance]], which integrates R into its other products.
* [[IBM]] provides commercial support for in-[[Hadoop]] execution of R.
* [[IBM]] provides commercial support for execution of R within [[Hadoop]].


== See also ==
== See also ==

Revision as of 18:16, 16 June 2025

Template:Short description Script error: No such module "about". Template:Use dmy dates Script error: No such module "Infobox".Template:Template otherScript error: No such module "Check for unknown parameters".

R is a programming language for statistical computing and data visualization. It has been widely adopted in the fields of data mining, bioinformatics, data analysis, and data science.[1]

The core R language is extended by a large number of software packages, which contain reusable code, documentation, and sample data. Some of the most popular R packages are in the tidyverse collection, which enhances functionality for visualizing, transforming, and modelling data, as well as improves the ease of programming (according to the authors and users).[2]

R is free and open-source software distributed under the GNU General Public License.[3][4] The language is implemented primarily in C, Fortran, and R itself. Precompiled executables are available for the major operating systems (including Linux, MacOS, and Microsoft Windows).

Its core is an interpreted language with a native command line interface. In addition, multiple third-party applications are available as graphical user interfaces; such applications include RStudio (an integrated development environment) and Jupyter (a notebook interface).

History

Script error: No such module "Gallery".

R was started by professors Ross Ihaka and Robert Gentleman as a programming language to teach introductory statistics at the University of Auckland.[5] The language was inspired by the S programming language, with most S programs able to run unaltered in R.[6] The language was also inspired by Scheme's lexical scoping, allowing for local variables.[7]

The name of the language, R, comes from being both an S language successor and the shared first letter of the authors, Ross and Robert.[8] In August 1993, Ihaka and Gentleman posted a binary file of R on StatLib — a data archive website.[9] At the same time, they announced the posting on the s-news mailing list.[10] On 5 December 1997, R became a GNU project when version 0.60 was released.[11] On 29 February 2000, the 1.0 version was released.[12]

Script error: No such module "anchor".Packages

Script error: No such module "Labelled list hatnote".

refer to caption
A violin plot created with the R package ggplot2 for data visualization

R packages are collections of functions, documentation, and data that expand R.[13] For example, packages can add reporting features (using packages such as RMarkdown, Quarto,[14] knitr, and Sweave) and support for various statistical techniques (such as linear, generalized linear and nonlinear modeling, classical statistical tests, spatial analysis, time-series analysis, and clustering). Ease of package installation and use have contributed to the language's adoption in data science.[15]

Immediately available when starting R after installation, base packages provide the fundamental and necessary syntax and commands for programming, computing, graphics production, basic arithmetic, and statistical functionality.[16]

An example is the tidyverse collection of R packages, which bundles several subsidiary packages to provide a common API. The collection specializes in tasks related to accessing and processing "tidy data",[17] which are data contained in a two-dimensional table with a single row for each observation and a single column for each variable.[18]

Installing a package occurs only once. For example, to install the tidyverse collection:[18]

> install.packages("tidyverse")

To load the functions, data, and documentation of a package, one calls the library() function. To load the tidyverse collection, one can execute the following code:Template:Efn

> # The package name can be enclosed in quotes
> library("tidyverse")

> # But the package name can also be used without quotes
> library(tidyverse)

The Comprehensive R Archive Network (CRAN) was founded in 1997 by Kurt Hornik and Friedrich Leisch to host R's source code, executable files, documentation, and user-created packages.[19] CRAN's name and scope mimic the Comprehensive TeX Archive Network (CTAN) and the Comprehensive Perl Archive Network (CPAN).[19] CRAN originally had only three mirror sites and twelve contributed packages.[20] Template:As of, it has 99 mirrors[21] and 21,513 contributed packages.[22] Packages are also available in repositories such as R-Forge, Omegahat, and GitHub.[23][24][25]

To provide guidance on the CRAN web site, its Task Views area lists packages that are relevant for specific topics; sample topics include causal inference, finance, genetics, high-performance computing, machine learning, medical imaging, meta-analysis, social sciences, and spatial statistics.

The Bioconductor project provides packages for genomic data analysis, complementary DNA, microarray, and high-throughput sequencing methods.

Community

There are three main groups that help support R software development:

  • The R Core Team was founded in 1997 to maintain the R source code.
  • The R Foundation for Statistical Computing was founded in April 2003 to provide financial support.
  • The R Consortium is a Linux Foundation project to develop R infrastructure.

The R Journal is an open access, academic journal that features short to medium-length articles on the use and development of R. The journal includes articles on packages, programming tips, CRAN news, and foundation news.

The R community hosts many conferences and in-person meetups.Template:Efn These groups include:

  • UseR!: an annual international R user conference (website)
  • Directions in Statistical Computing (DSC) (website)
  • R-Ladies: an organization to promote gender diversity in the R community (website)
  • SatRdays: R-focused conferences held on Saturdays (website)
  • R Conference (website)
  • posit::conf (formerly known as rstudio::conf) (website)

On social media sites such as Twitter, the hashtag #rstats can be used to follow new developments in the R community.[26]

Examples

Hello, World!

The following is a "Hello, World!" program:

> print("Hello, World!")
[1] "Hello, World!"

Here is an alternative version, which uses the cat() function:

> cat("Hello, World!")
Hello, World!

Basic syntax

The following examples illustrate the basic syntax of the language and use of the command-line interface.Template:Efn

In R, the generally preferred assignment operator is an arrow made from two characters <-, although = can be used in some cases.[27]

> x <- 1:6 # Create a numeric vector in the current environment
> y <- x^2 # Similarly, create a vector based on the values in x.
> print(y) # Print the vector’s contents.
[1]  1  4  9 16 25 36

> z <- x + y # Create a new vector that is the sum of x and y
> z # Return the contents of z to the current environment.
[1]  2  6 12 20 30 42

> z_matrix <- matrix(z, nrow = 3) # Create a new matrix that transforms the vector z into a 3x2 matrix object
> z_matrix 
     [,1] [,2]
[1,]    2   20
[2,]    6   30
[3,]   12   42

> 2 * t(z_matrix) - 2 # Transpose the matrix; multiply every element by 2; subtract 2 from each element in the matrix; and then return the results to the terminal.
     [,1] [,2] [,3]
[1,]    2   10   22
[2,]   38   58   82

> new_df <- data.frame(t(z_matrix), row.names = c("A", "B")) # Create a new dataframe object that contains the data from a transposed z_matrix, with row names 'A' and 'B'
> names(new_df) <- c("X", "Y", "Z") # Set the column names of the new_df dataframe as X, Y, and Z.
> print(new_df)  # Print the current results.
   X  Y  Z
A  2  6 12
B 20 30 42

> new_df$Z # Output the Z column
[1] 12 42

> new_df$Z == new_df['Z'] && new_df[3] == new_df$Z # The dataframe column Z can be accessed using the syntax $Z, ['Z'], or [3], and the values are the same. 
[1] TRUE

> attributes(new_df) # Print information about attributes of the new_df dataframe
$names
[1] "X" "Y" "Z"

$row.names
[1] "A" "B"

$class
[1] "data.frame"

> attributes(new_df)$row.names <- c("one", "two") # Access and then change the row.names attribute; this can also be done using the rownames() function
> new_df
     X  Y  Z
one  2  6 12
two 20 30 42

Structure of a function

R is able to create functions that add new functionality for code reuse.[28] Objects created within the body of the function (which are enclosed by curly brackets) remain accessible only from within the function, and any data type may be returned. In R, almost all functions and all user-defined functions are closures.[29]

The following is an example of creating a function to perform an arithmetic calculation:

# The function's input parameters are x and y.
# The function, named f, returns a linear combination of x and y.
f <- function(x, y) {
  z <- 3 * x + 4 * y

  # An explicit return() statement is optional--it could be replaced with simply `z` in this case.
  return(z)
}

# As an alternative, the last statement executed in a function is returned implicitly.
f <- function(x, y) 3 * x + 4 * y

The following is some output from using the function defined above:

> f(1, 2) #  3 * 1 + 4 * 2 = 3 + 8
[1] 11

> f(c(1, 2, 3), c(5, 3, 4)) # Element-wise calculation
[1] 23 18 25

> f(1:3, 4) # Equivalent to f(c(1, 2, 3), c(4, 4, 4))
[1] 19 22 25

It is possible to define functions to be used as infix operators by using the special syntax `%name%`, where "name" is the function variable name:

> `%sumx2y2%` <- function(e1, e2) {e1 ^ 2 + e2 ^ 2}
> 1:3 %sumx2y2% -(1:3)
[1]  2  8 18

Since R version 4.1.0, functions can be written in a short notation, which is useful for passing anonymous functions to higher-order functions:[30]

> sapply(1:5, \(i) i^2)    # here \(i) is the same as function(i) 
[1]  1  4  9 16 25

Native pipe operator

In R version 4.1.0, a native pipe operator, |>, was introduced.[31] This operator allows users to chain functions together, rather than using nested function calls.

> nrow(subset(mtcars, cyl == 4)) # Nested without the pipe character
[1] 11

> mtcars |> subset(cyl == 4) |> nrow() # Using the pipe character
[1] 11

Another alternative to nested functions is the use of intermediate objects, rather than the pipe operator:

> mtcars_subset_rows <- subset(mtcars, cyl == 4)
> num_mtcars_subset <- nrow(mtcars_subset_rows)
> print(num_mtcars_subset)
[1] 11

While the pipe operator can produce code that is easier to read, it is advisable to chain together at most 10-15 lines of code using this operator, as well as to chunk code into sub-tasks that are saved into objects having meaningful names.[32] The following is an example having fewer than 10 lines, which some readers may find difficult to grasp in the absence of intermediate named steps:

(\(x, n = 42, key = c(letters, LETTERS, " ", ":", ")"))
    strsplit(x, "")[[1]] |>
    (Vectorize(\(chr) which(chr == key) - 1))() |>
    (`+`)(n) |>
    (`%%`)(length(key)) |>
    (\(i) key[i + 1])() |>
    paste(collapse = "")
)("duvFkvFksnvEyLkHAErnqnoyr")

The following is a version of the preceding code that is easier to read:

default_key <- c(letters, LETTERS, " ", ":", ")")

f <- function(x, n = 42, key = default_key) {
    split_input <- strsplit(x, "")[[1]]
    results <- (Vectorize(\(chr) which(chr == key) - 1))(split_input) |>
        (`+`)(n) |>
        (`%%`)(length(key)) |>
        (\(i) key[i + 1])()
    combined_results <- paste(results, collapse = "")
    return(combined_results)
}

f("duvFkvFksnvEyLkHAErnqnoyr")

Object-oriented programming

The R language has native support for object-oriented programming. There are two native 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 Common Lisp Object System (CLOS), with formal classes (also derived from S) and generic methods, which supports multiple dispatch and multiple inheritance[33]

In the example below, summary() is a generic function that dispatches to different methods depending on whether its argument is a numeric vector or a factor:

> 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

Modeling and plotting

File:Plots from lm example.svg
Diagnostic plots for the model from the example code in the "Modeling and plotting" section (q.v. the plot.lm() function). Mathematical notation is allowed in labels, as shown in the lower left plot.

The R language has built-in support for data modeling and graphics. The following example shows how R can generate and plot a linear model with residuals.

# Create x and y values
x <- 1:6
y <- x^2

# Linear regression model: y = A + B * x
model <- lm(y ~ x)

# Display an in-depth summary of the model
summary(model)

# Create a 2-by-2 layout for figures
par(mfrow = c(2, 2))

# Output diagnostic plots of the model
plot(model)

The output from the summary() function in the preceding code block is as follows:

Residuals:
      1       2       3       4       5       6       7       8      9      10
 3.3333 -0.6667 -2.6667 -2.6667 -0.6667  3.3333

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)  -9.3333     2.8441  -3.282 0.030453 * 
x             7.0000     0.7303   9.585 0.000662 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.055 on 4 degrees of freedom
Multiple R-squared:  0.9583, Adjusted R-squared:  0.9478
F-statistic: 91.88 on 1 and 4 DF,  p-value: 0.000662

Mandelbrot set

File:Mandelbrot Creation Animation.gif
A Mandelbrot set as visualized in R. (Note: The colours in this image differ from the output of the sample code in the "Mandelbrot set" section.)

This example of a Mandelbrot set highlights the use of complex numbers. It models the first 20 iterations of the equation z = z2 + c, where c represents different complex constants.

To run this sample code, it is necessary to first install the package that provides the write.gif() function:

install.packages("caTools")

The sample code is as follows:

library(caTools)

jet.colors <-
    colorRampPalette(
        c("green", "pink", "#007FFF", "cyan", "#7FFF7F",
          "white", "#FF7F00", "red", "#7F0000"))

dx <- 1500 # define width
dy <- 1400 # define height

C  <-
    complex(
            real = rep(seq(-2.2, 1.0, length.out = dx), each = dy),
            imag = rep(seq(-1.2, 1.2, length.out = dy), times = dx)
            )

# reshape as matrix of complex numbers
C <- matrix(C, dy, dx)

# initialize output 3D array
X <- array(0, c(dy, dx, 20))

Z <- 0

# loop with 20 iterations
for (k in 1:20) {

  # the central difference equation
  Z <- Z^2 + C

  # capture the results
  X[, , k] <- exp(-abs(Z))
}

write.gif(
    X,
    "Mandelbrot.gif",
    col = jet.colors,
    delay = 100)

Version names

A CD with autographs on it
A CD of R Version 1.0.0, autographed by the core team of R, photographed in Quebec City in 2019

All R version releases from 2.14.0 onward have codenames that make reference to Peanuts comics and films.[34][35][36]

In 2018, core R developer Peter Dalgaard presented a history of R releases since 1997.[37] Some notable early releases before the named releases include the following:

  • Version 1.0.0, released on 29 February 2000, a leap day
  • Version 2.0.0, released on 4 October 2004, "which at least had a nice ring to it"[37]

The idea of naming R version releases was inspired by the naming system for Debian and Ubuntu versions. Dalgaard noted an additional reason for the use of Peanuts references in R codenames—the humorous observation that "everyone in statistics is a P-nut."[37]

R release codenames
Version Release date Name Peanuts reference Reference
4.5.1 2025-06-13 Great Square Root [38] [39]
4.5.0 2025-04-11 How About a Twenty-Six [40] [41]
4.4.3 2025-02-28 Trophy Case [42] [43]
4.4.2 2024-10-31 Pile of Leaves [44] [45]
4.4.1 2024-06-14 Race for Your Life [46] [47]
4.4.0 2024-04-24 Puppy Cup [48] [49]
4.3.3 2024-02-29 Angel Food Cake [50] [51]
4.3.2 2023-10-31 Eye Holes [52] [53]
4.3.1 2023-06-16 Beagle Scouts [54] [55]
4.3.0 2023-04-21 Already Tomorrow [56][57][58] [59]
4.2.3 2023-03-15 Shortstop Beagle [60] [61]
4.2.2 2022-10-31 Innocent and Trusting [62] [63]
4.2.1 2022-06-23 Funny-Looking Kid [64][65][66][67][68][69] [70]
4.2.0 2022-04-22 Vigorous Calisthenics [71] [72]
4.1.3 2022-03-10 One Push-Up [71] [73]
4.1.2 2021-11-01 Bird Hippie [74][75] [73]
4.1.1 2021-08-10 Kick Things [76] [77]
4.1.0 2021-05-18 Camp Pontanezen [78] [79]
4.0.5 2021-03-31 Shake and Throw [80] [81]
4.0.4 2021-02-15 Lost Library Book [82][83][84] [85]
4.0.3 2020-10-10 Bunny-Wunnies Freak Out [86] [87]
4.0.2 2020-06-22 Taking Off Again [88] [89]
4.0.1 2020-06-06 See Things Now [90] [91]
4.0.0 2020-04-24 Arbor Day [92] [93]
3.6.3 2020-02-29 Holding the Windsock [94] [95]
3.6.2 2019-12-12 Dark and Stormy Night See It was a dark and stormy night#Literature[96] [97]
3.6.1 2019-07-05 Action of the Toes [98] [99]
3.6.0 2019-04-26 Planting of a Tree [100] [101]
3.5.3 2019-03-11 Great Truth [102] [103]
3.5.2 2018-12-20 Eggshell Igloos [104] [105]
3.5.1 2018-07-02 Feather Spray [106] [107]
3.5.0 2018-04-23 Joy in Playing [108] [109]
3.4.4 2018-03-15 Someone to Lean On [110][111][112] [113]
3.4.3 2017-11-30 Kite-Eating Tree See Kite-Eating Tree[114] [115]
3.4.2 2017-09-28 Short Summer See It Was a Short Summer, Charlie Brown [116]
3.4.1 2017-06-30 Single Candle [117] [118]
3.4.0 2017-04-21 You Stupid Darkness [117] [119]
3.3.3 2017-03-06 Another Canoe [120] [121]
3.3.2 2016-10-31 Sincere Pumpkin Patch [122] [123]
3.3.1 2016-06-21 Bug in Your Hair [124] [125]
3.3.0 2016-05-03 Supposedly Educational [126] [127]
3.2.5 2016-04-11 Very, Very Secure Dishes [128] [129][130][131]
3.2.4 2016-03-11 Very Secure Dishes [128] [132]
3.2.3 2015-12-10 Wooden Christmas-Tree See A Charlie Brown Christmas[133] [134]
3.2.2 2015-08-14 Fire Safety [135][136] [137]
3.2.1 2015-06-18 World-Famous Astronaut [138] [139]
3.2.0 2015-04-16 Full of Ingredients [140] [141]
3.1.3 2015-03-09 Smooth Sidewalk [142]Script error: No such module "Unsubst". [143]
3.1.2 2014-10-31 Pumpkin Helmet See You're a Good Sport, Charlie Brown [144]
3.1.1 2014-07-10 Sock it to Me [145][146][147][148] [149]
3.1.0 2014-04-10 Spring Dance [98] [150]
3.0.3 2014-03-06 Warm Puppy [151] [152]
3.0.2 2013-09-25 Frisbee Sailing [153] [154]
3.0.1 2013-05-16 Good Sport [155] [156]
3.0.0 2013-04-03 Masked Marvel [157] [158]
2.15.3 2013-03-01 Security Blanket [159] [160]
2.15.2 2012-10-26 Trick or Treat [161] [162]
2.15.1 2012-06-22 Roasted Marshmallows [163] [164]
2.15.0 2012-03-30 Easter Beagle [165] [166]
2.14.2 2012-02-29 Gift-Getting Season See It's the Easter Beagle, Charlie Brown[167] [168]
2.14.1 2011-12-22 December Snowflakes [169] [170]
2.14.0 2011-10-31 Great Pumpkin See It's the Great Pumpkin, Charlie Brown[171] [172]
r-devel N/A Unsuffered Consequences [173] [37]

Interfaces

Script error: No such module "Gallery".

R is installed with a command line console by default, but there are multiple ways to interface with the language:

Statistical frameworks that use R in the background include Jamovi and JASP.Template:Fact

Implementations

The main R implementation is written primarily in C, Fortran, and R itself. Other implementations include the following:

Microsoft R Open (MRO) was an R implementation. As of 30 June 2021, Microsoft began to phase out MRO in favor of the CRAN distribution.[178]

Commercial support

Script error: No such module "anchor".

Although R is an open-source project, some companies provide commercial support:

  • Oracle provides commercial support for its Big Data Appliance, which integrates R into its other products.
  • IBM provides commercial support for execution of R within Hadoop.

See also

Notes

Template:Notelist

References

Template:Reflist

Further reading

  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".

External links

Template:R (programming language) Template:GNU Template:Numerical analysis software Template:Statistical software Script error: No such module "Navbox".

Template:Portal bar

Template:Authority control

  1. Script error: No such module "Citation/CS1".
  2. Script error: No such module "citation/CS1".
  3. Script error: No such module "citation/CS1".
  4. Script error: No such module "citation/CS1".
  5. Script error: No such module "citation/CS1".
  6. Cite error: Invalid <ref> tag; no text was provided for refs named R FAQ
  7. Cite error: Invalid <ref> tag; no text was provided for refs named Morandat
  8. Script error: No such module "citation/CS1".
  9. Script error: No such module "citation/CS1".
  10. Script error: No such module "citation/CS1".
  11. Script error: No such module "citation/CS1".
  12. Script error: No such module "citation/CS1".
  13. Script error: No such module "citation/CS1".
  14. Script error: No such module "citation/CS1".
  15. Script error: No such module "Citation/CS1".
  16. Script error: No such module "citation/CS1".
  17. Wickham, Hadley (2014). "Tidy Data" (PDF). Journal of Statistical Software. 59 (10). doi:10.18637/jss.v059.i10.
  18. a b Script error: No such module "citation/CS1".
  19. a b Script error: No such module "Citation/CS1".
  20. Template:Cite Q.
  21. Script error: No such module "citation/CS1".
  22. Script error: No such module "citation/CS1".
  23. Script error: No such module "citation/CS1".
  24. Script error: No such module "citation/CS1".
  25. Script error: No such module "citation/CS1".
  26. Script error: No such module "citation/CS1".
  27. Script error: No such module "citation/CS1".
  28. Script error: No such module "citation/CS1".
  29. Script error: No such module "citation/CS1".
  30. Script error: No such module "citation/CS1".
  31. Script error: No such module "citation/CS1".
  32. Script error: No such module "citation/CS1".
  33. Script error: No such module "citation/CS1".
  34. Script error: No such module "citation/CS1".
  35. Script error: No such module "citation/CS1".
  36. Script error: No such module "citation/CS1".
  37. a b c d Script error: No such module "citation/CS1".
  38. Script error: No such module "citation/CS1".
  39. Script error: No such module "citation/CS1".
  40. Script error: No such module "citation/CS1".
  41. Script error: No such module "citation/CS1".
  42. Script error: No such module "citation/CS1".
  43. Script error: No such module "citation/CS1".
  44. Script error: No such module "citation/CS1".
  45. Script error: No such module "citation/CS1".
  46. Script error: No such module "citation/CS1".
  47. Script error: No such module "citation/CS1".
  48. Script error: No such module "citation/CS1".
  49. Script error: No such module "citation/CS1".
  50. Script error: No such module "citation/CS1".
  51. Script error: No such module "citation/CS1".
  52. Script error: No such module "citation/CS1".
  53. Script error: No such module "citation/CS1".
  54. Script error: No such module "citation/CS1".
  55. Script error: No such module "citation/CS1".
  56. Script error: No such module "citation/CS1".
  57. Script error: No such module "citation/CS1".
  58. Script error: No such module "citation/CS1".
  59. Script error: No such module "citation/CS1".
  60. Script error: No such module "citation/CS1".
  61. Script error: No such module "citation/CS1".
  62. Script error: No such module "citation/CS1".
  63. Script error: No such module "citation/CS1".
  64. Script error: No such module "citation/CS1".
  65. Script error: No such module "citation/CS1".
  66. Script error: No such module "citation/CS1".
  67. Script error: No such module "citation/CS1".
  68. Script error: No such module "citation/CS1".
  69. Script error: No such module "citation/CS1".
  70. Script error: No such module "citation/CS1".
  71. a b Script error: No such module "citation/CS1".
  72. Script error: No such module "citation/CS1".
  73. a b Script error: No such module "citation/CS1".
  74. Script error: No such module "citation/CS1".
  75. Script error: No such module "citation/CS1".
  76. Script error: No such module "citation/CS1".
  77. Script error: No such module "citation/CS1".
  78. Script error: No such module "citation/CS1".
  79. Script error: No such module "citation/CS1".
  80. Script error: No such module "citation/CS1".
  81. Script error: No such module "citation/CS1".
  82. Script error: No such module "citation/CS1".
  83. Script error: No such module "citation/CS1".
  84. Script error: No such module "citation/CS1".
  85. Script error: No such module "citation/CS1".
  86. Script error: No such module "citation/CS1".
  87. Script error: No such module "citation/CS1".
  88. Script error: No such module "citation/CS1".
  89. Script error: No such module "citation/CS1".
  90. Script error: No such module "citation/CS1".
  91. Script error: No such module "citation/CS1".
  92. Script error: No such module "citation/CS1".
  93. Script error: No such module "citation/CS1".
  94. Script error: No such module "citation/CS1".
  95. Script error: No such module "citation/CS1".
  96. Script error: No such module "citation/CS1".
  97. Script error: No such module "citation/CS1".
  98. a b Script error: No such module "citation/CS1".
  99. Script error: No such module "citation/CS1".
  100. Script error: No such module "citation/CS1".
  101. Script error: No such module "citation/CS1".
  102. Script error: No such module "citation/CS1".
  103. Script error: No such module "citation/CS1".
  104. Script error: No such module "citation/CS1".
  105. Script error: No such module "citation/CS1".
  106. Script error: No such module "citation/CS1".
  107. Script error: No such module "citation/CS1".
  108. Script error: No such module "citation/CS1".
  109. Script error: No such module "citation/CS1".
  110. Script error: No such module "citation/CS1".
  111. Script error: No such module "citation/CS1".
  112. Script error: No such module "citation/CS1".
  113. Script error: No such module "citation/CS1".
  114. Script error: No such module "citation/CS1".
  115. Script error: No such module "citation/CS1".
  116. Script error: No such module "citation/CS1".
  117. a b Script error: No such module "citation/CS1".
  118. Script error: No such module "citation/CS1".
  119. Script error: No such module "citation/CS1".
  120. Script error: No such module "citation/CS1".
  121. Script error: No such module "citation/CS1".
  122. Script error: No such module "citation/CS1".
  123. Script error: No such module "citation/CS1".
  124. Script error: No such module "citation/CS1".
  125. Script error: No such module "citation/CS1".
  126. Script error: No such module "citation/CS1".
  127. Script error: No such module "citation/CS1".
  128. a b Script error: No such module "citation/CS1".
  129. Script error: No such module "citation/CS1".
  130. Script error: No such module "citation/CS1".
  131. Script error: No such module "citation/CS1".
  132. Script error: No such module "citation/CS1".
  133. Script error: No such module "citation/CS1".
  134. Script error: No such module "citation/CS1".
  135. Script error: No such module "citation/CS1".
  136. Script error: No such module "citation/CS1".
  137. Script error: No such module "citation/CS1".
  138. Script error: No such module "citation/CS1".
  139. Script error: No such module "citation/CS1".
  140. Script error: No such module "citation/CS1".
  141. Script error: No such module "citation/CS1".
  142. Script error: No such module "citation/CS1".
  143. Script error: No such module "citation/CS1".
  144. Script error: No such module "citation/CS1".
  145. Script error: No such module "citation/CS1".
  146. Script error: No such module "citation/CS1".
  147. Script error: No such module "citation/CS1".
  148. Script error: No such module "citation/CS1".
  149. Script error: No such module "citation/CS1".
  150. Script error: No such module "citation/CS1".
  151. Script error: No such module "citation/CS1".
  152. Script error: No such module "citation/CS1".
  153. Script error: No such module "citation/CS1".
  154. Script error: No such module "citation/CS1".
  155. Script error: No such module "citation/CS1".
  156. Script error: No such module "citation/CS1".
  157. Script error: No such module "citation/CS1".
  158. Script error: No such module "citation/CS1".
  159. Script error: No such module "citation/CS1".
  160. Script error: No such module "citation/CS1".
  161. Script error: No such module "citation/CS1".
  162. Script error: No such module "citation/CS1".
  163. Script error: No such module "citation/CS1".
  164. Script error: No such module "citation/CS1".
  165. Script error: No such module "citation/CS1".
  166. Script error: No such module "citation/CS1".
  167. Script error: No such module "Citation/CS1".
  168. Script error: No such module "citation/CS1".
  169. Script error: No such module "citation/CS1".
  170. Script error: No such module "citation/CS1".
  171. Script error: No such module "citation/CS1".
  172. Script error: No such module "citation/CS1".
  173. Script error: No such module "citation/CS1".
  174. Script error: No such module "citation/CS1".
  175. Script error: No such module "citation/CS1".
  176. Script error: No such module "citation/CS1".
  177. Jackson, Joab (16 May 2013). TIBCO offers free R to the enterprise. PC World. Retrieved 20 July 2015.
  178. Script error: No such module "citation/CS1".