{{short description|Extensions to the R statistical programming language}} alt=a big, blue R|thumb|R logo '''R packages''' are extensions to the R statistical programming language. R packages contain code, data, and documentation in a standardised collection format that can be installed by users of R, typically via a centralised software repository such as CRAN (the Comprehensive R Archive Network).<ref name="RFAQ7.29">{{cite web|last1=Hornik|first1=Kurt|date=2020-02-20|title=Frequently Asked Questions on R|url=https://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Add_002dOn-Packages|access-date=2 November 2020|website=The Comprehensive R Archive Network|location=7.29: What is the difference between package and library?|archive-date=2011-07-09|archive-url=https://web.archive.org/web/20110709085359/http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Add_002dOn-Packages|url-status=live}}</ref><ref>{{cite book |last1=Wickham |first1=Hadley |last2=Bryan |first2=Jennifer |title=R Packages |edition=2nd |url=https://r-pkgs.org/intro.html |chapter=Introduction |access-date=2020-11-02 |archive-date=2022-06-29 |archive-url=https://web.archive.org/web/20220629062757/https://r-pkgs.org/intro.html |url-status=live }}</ref> The large number of packages available for R, and the ease of installing and using them, has been cited as a major factor driving the widespread adoption of the language in data science.<ref name=":0">{{Cite journal|last=Chambers|first=John M.|date=2020|title=S, R, and Data Science|url=https://journal.r-project.org/archive/2020/RJ-2020-028/index.html|journal=The R Journal|language=en|volume=12|issue=1|pages=462–476|doi=10.32614/RJ-2020-028|issn=2073-4859|doi-access=free|access-date=2020-11-02|archive-date=2020-11-01|archive-url=https://web.archive.org/web/20201101065701/https://journal.r-project.org/archive/2020/RJ-2020-028/index.html|url-status=live}}</ref><ref>{{cite news|last=Vance|first=Ashlee|author-link=Ashlee Vance|date=2009-01-06|title=Data Analysts Captivated by R's Power|work=New York Times|url=https://www.nytimes.com/2009/01/07/technology/business-computing/07program.html|access-date=2020-11-02|archive-date=2021-05-02|archive-url=https://web.archive.org/web/20210502082437/https://www.nytimes.com/2009/01/07/technology/business-computing/07program.html|url-status=live}}</ref><ref>{{Cite journal|last=Tippmann|first=Sylvia|date=2014-12-29|title=Programming tools: Adventures with R|journal=Nature News|language=en|volume=517|issue=7532|pages=109–110|doi=10.1038/517109a|pmid=25557714 |doi-access=free}}</ref><ref name=":1">{{Cite journal|last=Thieme|first=Nick|date=2018|title=R generation|journal=Significance|language=en|volume=15|issue=4|pages=14–19|doi=10.1111/j.1740-9713.2018.01169.x|issn=1740-9713|doi-access=free}}</ref>
Compared to libraries in other programming languages, R packages must conform to a relatively strict specification.<ref name=":0" /> The ''Writing R Extensions'' manual<ref>{{Cite web|title=Writing R Extensions|url=https://cran.r-project.org/doc/manuals/r-release/R-exts.html|access-date=2020-11-02|website=The Comprehensive R Archive Network|archive-date=2020-11-12|archive-url=https://web.archive.org/web/20201112034046/https://cran.r-project.org/doc/manuals/r-release/R-exts.html|url-status=live}}</ref> specifies a standard directory structure for R source code, data, documentation, and package metadata, which enables them to be installed and loaded using R's in-built package management tools.<ref name=":0" /> Packages distributed on CRAN must meet additional standards.<ref name=":0" /><ref>{{Cite web|title=CRAN Repository Policy|url=https://cran.r-project.org/web/packages/policies.html|access-date=2020-11-02|website=The Comprehensive R Archive Network|archive-date=2020-11-05|archive-url=https://web.archive.org/web/20201105093336/https://cran.r-project.org/web/packages/policies.html|url-status=live}}</ref> According to John Chambers, whilst these requirements "impose considerable demands" on package developers, they improve the usability and long-term stability of packages for end users.<ref name=":0" />
== Repositories == === Comprehensive R Archive Network (CRAN) === alt=basic website homepage with mostly text in boxes and links in blue, with the title "The Comprehensive R Archive Network" at the top and the R programming language logo in the top left corner|thumb|The Comprehensive R Archive Network (CRAN) homepage The Comprehensive R Archive Network (CRAN) is R's central software repository, supported by the R Foundation.<ref name="CRAN Repository Policy">{{cite web |author1=CRAN Repository Maintainers |title=CRAN Repository Policy |url=https://cran.r-project.org/web/packages/policies.html |website=The Comprehensive R Archive Network |publisher=R Project |access-date=20 November 2020 |archive-date=11 November 2020 |archive-url=https://web.archive.org/web/20201111222757/https://cran.r-project.org/web/packages/policies.html |url-status=live }}</ref> It contains an archive of the latest and previous versions of the R distribution, documentation, and contributed R packages.<ref name="RFAQ2.10">{{cite web|last1=Hornik|first1=Kurt|date=2020-02-20|title=Frequently Asked Questions on R|url=https://cran.r-project.org/doc/FAQ/R-FAQ.html#What-is-CRAN_003f|access-date=20 November 2020|website=The Comprehensive R Archive Network|publisher=R Project|location=2.1: What is CRAN?|archive-date=2011-07-09|archive-url=https://web.archive.org/web/20110709085359/http://cran.r-project.org/doc/FAQ/R-FAQ.html#What-is-CRAN_003f|url-status=live}}</ref> It includes both source packages and pre-compiled binaries for Windows and macOS.<ref>{{cite web |author=CRAN Repository Maintainers |title=The Comprehensive R Archive Network |url=https://cran.r-project.org/ |publisher=R Project |access-date=20 November 2020 |archive-date=23 January 2019 |archive-url=https://web.archive.org/web/20190123091845/https://cran.r-project.org/ |url-status=live }}</ref> {{As of|November 2020}}, more than 16,000 packages are available.<ref>{{cite web |author=CRAN Repository Maintainers |title=CRAN - Contributed Packages |url=https://cran.r-project.org/web/packages |website=The Comprehensive R Archive Network |publisher=CRAN |access-date=20 November 2020 |archive-date=24 November 2020 |archive-url=https://web.archive.org/web/20201124034305/http://cran.r-project.org/web/packages/ |url-status=live }}</ref> CRAN was created by Kurt Hornik and Friedrich Leisch in 1997,<ref>{{cite mailing list |url=https://stat.ethz.ch/pipermail/r-announce/1997/000001.html |title=ANNOUNCE: CRAN |date=1997-04-23 |access-date=20 November 2020 |mailing-list=r-announce |last=Hornik |first=Kurt |author-link=Kurt Hornik |archive-date=2021-03-08 |archive-url=https://web.archive.org/web/20210308080935/https://stat.ethz.ch/pipermail/r-announce/1997/000001.html |url-status=live }}</ref><ref>{{cite journal |last1=Thieme |first1=Nick |title=R generation |journal=Significance |date=2018 |volume=15 |issue=4 |pages=14–19 |doi=10.1111/j.1740-9713.2018.01169.x |language=en |issn=1740-9713|doi-access=free }}</ref> with the name paralleling other early packing systems such as TeX's CTAN (released 1992) and Perl's CPAN (released 1995).<ref>{{cite web |last1=Fitzgerald |first1=Brian |title=A Survey of Programming Language Package Systems |url=https://neurocline.github.io/papers/survey-of-programming-language-packaging-systems.html |website=Some Things Are Obvious |access-date=4 May 2021 |date=2016-02-09 |archive-date=2020-11-09 |archive-url=https://web.archive.org/web/20201109001211/http://neurocline.github.io/papers/survey-of-programming-language-packaging-systems.html |url-status=live }}</ref> {{As of|2021}}, it is still maintained by Hornik and a team of volunteers.<ref name="CRAN Repository Policy" /> The master site is located at the Vienna University of Economics and Business and is mirrored on servers around the world.<ref name="RFAQ2.10" /> thumb|Homepage for R CRAN Task Views The "Task Views" page (subject list) on the CRAN website<ref name=CRANTasks>{{cite web|title=CRAN Task Views|url=https://cran.r-project.org/web/views/|website=cran.r-project.org|access-date=2018-09-16|archive-date=2011-07-09|archive-url=https://web.archive.org/web/20110709090110/http://cran.r-project.org/web/views/|url-status=live}}</ref> lists a wide range of tasks (in fields such as finance, genetics, high performance computing, machine learning, medical imaging, meta-analysis, social sciences and spatial statistics) for which R packages are available. Another way to browse CRAN packages is provided by Metacran,<ref name="metacran" /> which also maintains lists of featured, most downloaded, trending or most depended upon packages.
The number of CRAN packages has grown exponentially for many years,<ref>{{Cite web|date=April 21, 2016|first=Matt|last=Asay|title=Exponential growth of R's open source community threatens commercial competitors|url=https://www.techrepublic.com/article/exponential-growth-of-rs-open-source-community-threatens-commercial-competitors/|access-date=2020-11-02|website=TechRepublic|language=en|archive-date=2020-10-26|archive-url=https://web.archive.org/web/20201026135007/https://www.techrepublic.com/article/exponential-growth-of-rs-open-source-community-threatens-commercial-competitors/|url-status=live}}</ref> and {{As of|2018|lc=y}} an average of 21 submissions of new or updated packages were made every day.<ref name=":1" /> Since each submission is manually reviewed by a small team of CRAN maintainers, many of whom, according to R core developer Peter Dalgaard, are "approaching pensionable age", there is a concern that this system is not sustainable in the long term.<ref name=":1" /> The growth of CRAN has exposed limitations of its dependency management infrastructure, particularly the fact that it assumes that dependencies always refer to the latest version of a package, meaning that new releases of CRAN packages must always be backwards compatible,<ref>{{Cite journal|last=Ooms|first=Jeroen|date=2013|title=Possible Directions for Improving Dependency Versioning in R|url=https://journal.r-project.org/archive/2013/RJ-2013-019/index.html|journal=The R Journal|language=en|volume=5|issue=1|pages=197–206|doi=10.32614/RJ-2013-019|s2cid=6791850|issn=2073-4859|doi-access=free|access-date=2020-11-02|archive-date=2020-09-19|archive-url=https://web.archive.org/web/20200919032710/https://journal.r-project.org/archive/2013/RJ-2013-019/index.html|url-status=live|arxiv=1303.2140}}</ref> and that CRAN packages cannot have dependencies that are not on CRAN.<ref>{{Cite book|last1=Decan|first1=A.|last2=Mens|first2=T.|last3=Claes|first3=M.|last4=Grosjean|first4=P.|title=2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER)|chapter=When GitHub Meets CRAN: An Analysis of Inter-Repository Package Dependency Problems|date=2016|volume=1|pages=493–504|doi=10.1109/SANER.2016.12|isbn=978-1-5090-1855-0|s2cid=16751624}}</ref> It has also led to concerns about declining quality of packages.<ref>{{Cite journal|last=Hornik|first=Kurt|date=2012|title=Are There Too Many R Packages?|url=https://www.ajs.or.at/index.php/ajs/article/view/vol41%2C%20no1%20-%205|journal=Austrian Journal of Statistics|language=en|volume=41|issue=1|pages=59–66–59–66|doi=10.17713/ajs.v41i1.188|issn=1026-597X|doi-access=free|access-date=2020-11-02|archive-date=2020-11-26|archive-url=https://web.archive.org/web/20201126100052/https://ajs.or.at/index.php/ajs/article/view/vol41%2C%20no1%20-%205|url-status=live}}</ref>
===MRAN and Posit Package Manager=== thumb|Homepage for the Microsoft R Application Network (MRAN) The Microsoft R Application Network (MRAN) is a mirror of CRAN maintained by Microsoft which is based on the company's downstream distribution of R, Microsoft R Open (formerly Revolution R Open).<ref>{{cite web |title=Welcome to MRAN |url=https://mran.microsoft.com/ |website=Microsoft R Application Network |publisher=Microsoft |access-date=4 May 2021 |archive-date=4 May 2021 |archive-url=https://web.archive.org/web/20210504233105/https://mran.microsoft.com/ |url-status=live }}</ref> It also includes an archive of daily CRAN snapshots, branded as the "CRAN Time Machine", which enables users of MRAN to bypass the dependency versioning limitations of CRAN by installing a fixed set of R package versions via the package checkpoint.<ref>{{cite web |title=Reproducibility: Using Fixed CRAN Repository Snapshots |url=https://mran.microsoft.com/documents/rro/reproducibility |website=Microsoft R Application Network |publisher=Microsoft |access-date=4 May 2021 |archive-date=2 May 2021 |archive-url=https://web.archive.org/web/20210502235101/https://mran.microsoft.com/documents/rro/reproducibility |url-status=live }}</ref><ref>{{cite web |last1=Smith |first1=David |title=MRAN snapshots, and you |url=https://blog.revolutionanalytics.com/2019/05/cran-snapshots-and-you.html |website=Revolutions |publisher=Revolution Analytics |access-date=4 May 2021 |date=2019-05-22 |archive-date=2021-05-04 |archive-url=https://web.archive.org/web/20210504113027/https://blog.revolutionanalytics.com/2019/05/cran-snapshots-and-you.html |url-status=live }}</ref> In January 2023 Microsoft announced that MRAN was being retired and the associated websites and repositories became unavailable in July 2023.<ref>{{Cite web |title=Microsoft R Application Network retirement |url=https://techcommunity.microsoft.com/t5/azure-sql-blog/microsoft-r-application-network-retirement/ba-p/3707161 |access-date=2023-11-15 |website=techcommunity.microsoft.com |language=en}}</ref> thumb|Homepage for the Posit Package Manager The Posit Package Manager (formerly RStudio Package Manager) is a similar tool produced by the developers of RStudio which, in addition to CRAN snapshots, includes an archive of R packages from Bioconductor and Python packages from the Python Package Index.<ref name="RStudio Blog 2020-12-07">{{cite web |last1=Lopp |first1=Sean |title=RStudio Package Manager 1.2.0 - Bioconductor & PyPI |url=https://blog.rstudio.com/2020/12/07/package-manager-1-2-0/ |website=RStudio Blog |publisher=RStudio |access-date=4 May 2021 |language=en-us |date=2020-12-07 |archive-date=2021-05-04 |archive-url=https://web.archive.org/web/20210504113028/https://blog.rstudio.com/2020/12/07/package-manager-1-2-0/ |url-status=live }}</ref> It also distributes pre-compiled binary packages for Linux (only Windows and macOS binaries are included on CRAN).<ref>{{cite web |last1=Lopp |first1=Sean |title=Announcing Public Package Manager and v1.1.6 |url=https://blog.rstudio.com/2020/07/01/announcing-public-package-manager/ |access-date=4 May 2021 |website=RStudio Blog |publisher=RStudio |date=2020-07-01 |language=en-us |archive-date=2021-05-04 |archive-url=https://web.archive.org/web/20210504155150/https://blog.rstudio.com/2020/07/01/announcing-public-package-manager/ |url-status=live }}</ref>
=== Other repositories ===
The Bioconductor project provides R packages for the analysis of genomic data. This includes object-oriented data-handling and analysis tools for data from Affymetrix, cDNA microarray, and next-generation high-throughput sequencing methods.<ref>{{cite journal |date=2015 |title=Orchestrating high-throughput genomic analysis with Bioconductor |journal=Nature Methods |publisher=Nature Publishing Group |volume=12 |issue=2 |pages=115–121 |doi=10.1038/nmeth.3252 |pmid=25633503 |pmc=4509590 | last1 = Huber | first1 = W | last2 = Carey | first2 = VJ | last3 = Gentleman | first3 = R |author-link3= Robert Gentleman (statistician)| last4 = Anders | first4 = S | last5 = Carlson | first5 = M | last6 = Carvalho | first6 = BS | last7 = Bravo | first7 = HC | last8 = Davis | first8 = S | last9 = Gatto | first9 = L | last10 = Girke | first10 = T | last11 = Gottardo | first11 = R | last12 = Hahne | first12 = F | last13 = Hansen | first13 = KD | last14 = Irizarry | first14 = RA |author-link14=Rafael Irizarry (scientist) | last15 = Lawrence | first15 = M | last16 = Love | first16 = MI | last17 = MacDonald | first17 = J | last18 = Obenchain | first18 = V | last19 = Oleś | first19 = AK | last20 = Pagès | first20 = H | last21 = Reyes | first21 = A | last22 = Shannon | first22 = P | last23 = Smyth | first23 = GK | last24 = Tenenbaum | first24 = D | last25 = Waldron | first25 = L | last26 = Morgan | first26 = M}}</ref> thumb|Homepage for R-Forge R-Forge,<ref>{{cite web|url=https://r-forge.r-project.org/|title=R-Forge: Welcome|access-date=2018-09-16|archive-date=2018-09-14|archive-url=https://web.archive.org/web/20180914122834/http://r-forge.r-project.org/|url-status=live}}</ref> is a central platform for the collaborative development of R packages, R-related software, and projects. R-Forge also hosts many unpublished beta packages, and development versions of CRAN packages.
== Base and recommended packages == R is distributed with fifteen "base packages": base, compiler, datasets, grDevices, graphics, grid, methods, parallel, splines, stats, stats4, tcltk, tools, translations, and utils.<ref name="RFAQ5.1">{{cite web|last1=Hornik|first1=Kurt|date=2020-02-20|title=Frequently Asked Questions on R|url=https://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Add_002dOn-Packages|access-date=2 November 2020|website=The Comprehensive R Archive Network|location=5.1: Which add-on packages exist for R?|archive-date=2011-07-09|archive-url=https://web.archive.org/web/20110709085359/http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Add_002dOn-Packages|url-status=live}}</ref>
In addition, there are fifteen "recommended packages" from CRAN which are included with binary distributions of R: KernSmooth, MASS, Matrix, boot, class, cluster, codetools, foreign, lattice, mgcv, nlme, nnet, rpart, spatial, and survival.<ref name="RFAQ5.1" />
==Other packages== A group of packages called the tidyverse, which can be considered a "dialect of the R language", is increasingly popular in the R ecosystem. As of 1 August 2025, Metacran listed 6 of the 8 core packages of the tidyverse in the list of most downloaded R packages.<ref name=metacran>{{cite web|url=https://www.r-pkg.org/downloaded|title=Metacran|access-date=1 August 2025|archive-date=1 August 2025|archive-url=https://web.archive.org/web/20250801065130/https://www.r-pkg.org/downloaded|url-status=live}}</ref> The group of packages strives to provide a cohesive collection of functions to deal with common data science tasks, including data import, cleaning, transformation and visualisation (notably with the ggplot2 package).
The R Infrastructure packages support coding and the development of R packages and as of 1 August 2025, Metacran lists 8 of these packages among the 25 most downloaded packages.<ref name=metacran></ref><ref>{{cite web |title=R infrastructure |url=https://r-lib.r-universe.dev/builds |website=R-universe |access-date=1 August 2025}}</ref>
==See also== * tidyverse * ggplot2 * knitr
==References== {{Reflist}}
== Further reading ==
* {{Cite book |last1=Wickham |first1=Hadley |url=https://r-pkgs.org/ |title=R Packages: Organize, Test, Document, and Share Your Code |last2=Bryan |first2=Jennifer |date=July 25, 2023 |publisher=O'Reilly |isbn=978-1098134945 |edition=2nd |location=}} * {{Cite book|last1=Claes|first1=M.|last2=Mens|first2=T.|last3=Grosjean|first3=P.|title=2014 Software Evolution Week - IEEE Conference on Software Maintenance, Reengineering, and Reverse Engineering (CSMR-WCRE) |chapter=On the maintainability of CRAN packages |date=2014|pages=308–312|doi=10.1109/CSMR-WCRE.2014.6747183|isbn=978-1-4799-3752-3|s2cid=17927576}} * {{Cite book|last1=Decan|first1=Alexandre|last2=Mens|first2=Tom|last3=Claes|first3=Maelick|last4=Grosjean|first4=Philippe|title=Proceedings of the 2015 European Conference on Software Architecture Workshops |chapter=On the Development and Distribution of R Packages |date=2015-09-07|chapter-url=https://doi.org/10.1145/2797433.2797476|series=ECSAW '15|location=Dubrovnik, Cavtat, Croatia|publisher=Association for Computing Machinery|pages=1–6|doi=10.1145/2797433.2797476|isbn=978-1-4503-3393-1|s2cid=1680582|url=https://zenodo.org/record/851546 }} * {{cite journal |last1=Fox |first1=John |title=Aspects of the Social Organization and Trajectory of the R Project |journal=The R Journal |date=2009 |volume=1 |issue=2 |pages=5–13 |doi=10.32614/RJ-2009-014 |url=https://journal.r-project.org/archive/2009/RJ-2009-014/index.html |language=en |issn=2073-4859|doi-access=free |url-access=subscription }} * {{cite journal |last1=Fox |first1=John |last2=Leanage |first2=Allison |title=R and the Journal of Statistical Software |journal=Journal of Statistical Software |date=12 September 2016 |volume=73 |issue=1 |pages=1–13 |doi=10.18637/jss.v073.i02 |url=https://www.jstatsoft.org/article/view/v073i02 |language=en |issn=1548-7660|doi-access=free }} * {{Cite journal|last1=Plakidas|first1=Konstantinos|last2=Schall|first2=Daniel|last3=Zdun|first3=Uwe|date=2017|title=Evolution of the R software ecosystem: Metrics, relationships, and their impact on qualities|url=http://www.sciencedirect.com/science/article/pii/S0164121217301371|journal=Journal of Systems and Software|language=en|volume=132|pages=119–146|doi=10.1016/j.jss.2017.06.095|issn=0164-1212|url-access=subscription}}
== External links == * [https://cran.r-project.org/ The Comprehensive R Archive Network (CRAN)] * [https://www.r-pkg.org/ METACRAN], a directory of R packages *[https://cran.r-project.org/web/views/ CRAN Task Views], listing of CRAN packages by topics * [https://web.archive.org/web/20230601215249/https://mran.microsoft.com/ Microsoft R Application Network] (archived on the Wayback Machine)
{{R (programming language)}}
Category:R (programming language)