Everipedia Logo
Everipedia is now IQ.wiki - Join the IQ Brainlist and our Discord for early access to editing on the new platform and to participate in the beta testing.
R (programming language)

R (programming language)

R is a programming language and free software environment for statistical computing and graphics supported by the R Foundation for Statistical Computing.[6] The R language is widely used among statisticians and data miners for developing statistical software[7] and data analysis.[8] Polls, data mining surveys, and studies of scholarly literature databases show substantial increases in popularity;[9] as of September 2019, R ranks 19th in the TIOBE index, a measure of popularity of programming languages.[10]

A GNU package,[11] source code for the R software environment is written primarily in C, Fortran, and R itself[12] and is freely available under the GNU General Public License. Pre-compiled binary versions are provided for various operating systems. Although R has a command line interface, there are several graphical user interfaces, such as RStudio, an integrated development environment.[13][14]

R
R Terminal.png
R terminal
ParadigmsMulti-paradigm: Array, object-oriented, imperative, functional, procedural, reflective
Designed byRoss Ihaka and Robert Gentleman
DeveloperR Core Team[1]
First appearedAugust 1993 (1993-08)[2]
Stable release
3.6.1 ("Action of the Toes")[3] / July 5, 2019 (2019-07-05)
Typing disciplineDynamic
LicenseGNU GPL v2[4]
Filename extensions.r, .R, .RData, .rds, .rda
Websitewww.r-project.org [133]
Influenced by
  • Common Lisp
  • S
  • Scheme[2]
  • XLispStat
Influenced
Julia[5]
  • R Programming at Wikibooks

History

R is an implementation of the S programming language combined with lexical scoping semantics, inspired by Scheme.[15] S was created by John Chambers in 1976, while at Bell Labs. There are some important differences, but much of the code written for S runs unaltered.[16]

R was created by Ross Ihaka and Robert Gentleman[17] at the University of Auckland, New Zealand, and is currently developed by the R Development Core Team (of which Chambers is a member).[18] R is named partly after the first names of the first two R authors and partly as a play on the name of S.[19] The project was conceived in 1992, with an initial version released in 1995 and a stable beta version in 2000.[20][21][22]

Statistical features

R and its libraries implement a wide variety of statistical and graphical techniques, including linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, and others. R is easily extensible through functions and extensions, and the R community is noted for its active contributions in terms of packages. Many of R's standard functions are written in R itself, which makes it easy for users to follow the algorithmic choices made. For computationally intensive tasks, C, C++, and Fortran code can be linked and called at run time. Advanced users can write C, C++,[23] Java,[24] .NET[25] or Python code to manipulate R objects directly.[26] R is highly extensible through the use of user-submitted packages for specific functions or specific areas of study. Due to its S heritage, R has stronger object-oriented programming facilities than most statistical computing languages. Extending R is also eased by its lexical scoping rules.[27]

Another strength of R is static graphics, which can produce publication-quality graphs, including mathematical symbols. Dynamic and interactive graphics are available through additional packages.[28]

R has Rd, its own LaTeX-like documentation format, which is used to supply comprehensive documentation, both online in a number of formats and in hard copy.[29]

Programming features

R is an interpreted language; users typically access it through a command-line interpreter. If a user types 2+2 at the R command prompt and presses enter, the computer replies with 4, as shown below:

This calculation is interpreted as the sum of two single-element vectors, resulting in a single-element vector. The prefix [1] indicates that the list of elements following it on the same line starts with the first element of the vector (a feature that is useful when the output extends over multiple lines).

Like other similar languages such as APL and MATLAB, R supports matrix arithmetic. R's data structures include vectors, matrices, arrays, data frames (similar to tables in a relational database) and lists.[30] Arrays are stored in column-major order.[31] R's extensible object system includes objects for (among others): regression models, time-series and geo-spatial coordinates. The scalar data type was never a data structure of R.[32] Instead, a scalar is represented as a vector with length one.[33]

Many features of R derive from Scheme. R uses S-expressions to represent both data and code. Functions are first-class and can be manipulated in the same way as data objects, facilitating meta-programming, and allow multiple dispatch. Variables in R are lexically scoped and dynamically typed. Function arguments are passed by value, and are lazy—that is to say, they are only evaluated when they are used, not when the function is called.

R supports procedural programming with functions and, for some functions, object-oriented programming with generic functions. A generic function acts differently depending on the classes of arguments passed to it. In other words, the generic function dispatches the function (method) specific to that class of object. For example, R has a generic print function that can print almost every class of object in R with a simple print(objectname) syntax.[34]

Although used mainly by statisticians and other practitioners requiring an environment for statistical computation and software development, R can also operate as a general matrix calculation toolbox – with performance benchmarks comparable to GNU Octave or MATLAB.[35]

Packages

The capabilities of R are extended through user-created packages, which allow specialised statistical techniques, graphical devices, import/export capabilities, reporting tools (Rmarkdown, knitr, Sweave), etc. These packages are developed primarily in R, and sometimes in Java, C, C++, and Fortran. The R packaging system is also used by researchers to create compendia to organise research data, code and report files in a systematic way for sharing and public archiving.[36]

A core set of packages is included with the installation of R, with more than 15,000 additional packages (as of September 2018) available at the Comprehensive R Archive Network (CRAN),[37] Bioconductor, Omegahat,[38] GitHub, and other repositories.[39]

The "Task Views" page (subject list) on the CRAN website[40] lists a wide range of tasks (in fields such as Finance, Genetics, High Performance Computing, Machine Learning, Medical Imaging, Social Sciences and Spatial Statistics) to which R has been applied and for which packages are available. R has also been identified by the FDA as suitable for interpreting data from clinical research.[41]

Other R package resources include Crantastic,[42] a community site for rating and reviewing all CRAN packages, and R-Forge,[43] 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.

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.[44]

Milestones

A list of changes in R releases is maintained in various "news" files at CRAN.[45] Some highlights are listed below for several major releases.

ReleaseDateDescription
0.16This is the last alpha version developed primarily by Ihaka and Gentleman. Much of the basic functionality from the "White Book" (see S history) was implemented. The mailing lists commenced on April 1, 1997.
0.491997-04-23This is the oldest source release which is currently available on CRAN.[46] CRAN is started on this date, with 3 mirrors that initially hosted 12 packages.[47] Alpha versions of R for Microsoft Windows and the classic Mac OS are made available shortly after this version.
0.601997-12-05R becomes an official part of the GNU Project. The code is hosted and maintained on CVS.
0.65.11999-10-07First versions of update.packages and install.packages functions for downloading and installing packages from CRAN.[48]
1.02000-02-29Considered by its developers stable enough for production use.[49]
1.42001-12-19S4 methods are introduced and the first version for Mac OS X is made available soon after.
1.82003-10-08Introduced a flexible condition handling mechanism for signalling and handling condition objects.
2.02004-10-04Introduced lazy loading, which enables fast loading of data with minimal expense of system memory.
2.12005-04-18Support for UTF-8 encoding, and the beginnings of internationalization and localization for different languages.
2.112010-04-22Support for Windows 64 bit systems.
2.132011-04-14Adding a new compiler function that allows speeding up functions by converting them to byte-code.
2.142011-10-31Added mandatory namespaces for packages. Added a new parallel package.
2.152012-03-30New load balancing functions. Improved serialisation speed for long vectors.
3.02013-04-03Support for numeric index values 231and larger on 64 bit systems.
3.42017-04-21Just-in-time compilation (JIT) of functions and loops to byte-code enabled by default.
3.52018-04-23Packages byte-compiled on installation by default. Compact internal representation of integer sequences. Added a new serialisation format to support compact internal representations.

Interfaces

The most specialized integrated development environment (IDE) for R is RStudio.[50] A similar development interface is R Tools for Visual Studio. Some generic IDEs like Eclipse,[51] also offer features to work with R.

Graphical user interfaces with more of a point-and-click approach include Rattle GUI, R Commander, and RKWard.

Some of the more common editors with varying levels of support for R include Emacs (Emacs Speaks Statistics), Vim (Nvim-R plugin[52]), Neovim (Nvim-R plugin[52]), Kate,[53] LyX,[54] Notepad++,[55] Visual Studio Code, WinEdt,[56] and Tinn-R.[57]

R functionality is accessible from several scripting languages such as Python,[58] Perl,[59] Ruby,[60] F#,[61] and Julia.[62] Interfaces to other, high-level programming languages, like Java[63] and .NET C#[64][65] are available as well.

Implementations

The main R implementation is written in R, C, and Fortran,[66] and there are several other implementations aimed at improving speed or increasing extensibility. A closely related implementation is pqR (pretty quick R) by Radford M. Neal with improved memory management and support for automatic multithreading. Renjin and FastR are Java implementations of R for use in a Java Virtual Machine. CXXR, rho, and Riposte[67] are implementations of R in C++. Renjin, Riposte, and pqR attempt to improve performance by using multiple processor cores and some form of deferred evaluation.[68] Most of these alternative implementations are experimental and incomplete, with relatively few users, compared to the main implementation maintained by the R Development Core Team.

TIBCO built a runtime engine called TERR, which is part of Spotfire.[69]

Microsoft R Open is a fully compatible R distribution with modifications for multi-threaded computations.[70]

R communities

R has local communities worldwide for users to network, share ideas, and learn.[71][72]

There is a growing number of R events bringing its users together, such as conferences (e.g. useR!, WhyR?, conectaR, SatRdays),[73][74] meetups,[75] as well as R-Ladies[76] groups that promote gender diversity.

useR! conferences

The official annual gathering of R users is called "useR!".[77] The first such event was useR! 2004 in May 2004, Vienna, Austria.[78] After skipping 2005, the useR! conference has been held annually, usually alternating between locations in Europe and North America.[79] Subsequent conferences have included:[77]

  • useR! 2006, Vienna, Austria

  • useR! 2007, Ames, Iowa, USA

  • useR! 2008, Dortmund, Germany

  • useR! 2009, Rennes, France

  • useR! 2010, Gaithersburg, Maryland, USA

  • useR! 2011, Coventry, United Kingdom

  • useR! 2012, Nashville, Tennessee, USA

  • useR! 2013, Albacete, Spain

  • useR! 2014, Los Angeles, California, USA

  • useR! 2015, Aalborg, Denmark

  • useR! 2016, Stanford, California, USA

  • useR! 2017, Brussels, Belgium

  • useR! 2018, Brisbane, Australia

  • useR! 2019, Toulouse, France

Future conferences planned are as follows:[77]

  • useR! 2020, St. Louis, Missouri, USA

The R Journal

The R Journal is the open access, refereed journal of the R project for statistical computing. It features short to medium length articles on the use and development of R, including packages, programming tips, CRAN news, and foundation news.

Comparison with SAS, SPSS, and Stata

R is comparable to popular commercial statistical packages such as SAS, SPSS, and Stata, but R is available to users at no charge under a free software license.[80]

In January 2009, the New York Times ran an article charting the growth of R, the reasons for its popularity among data scientists and the threat it poses to commercial statistical packages such as SAS.[81] In June 2017 data scientist Robert Muenchen published a more in-depth comparison between R and other software packages, "The Popularity of Data Science Software".[82]

Commercial support for R

Although R is an open-source project supported by the community developing it, some companies strive to provide commercial support and/or extensions for their customers. This section gives some examples of such companies.

In 2007, Richard Schultz, Martin Schultz, Steve Weston and Kirk Mettler founded Revolution Analytics to provide commercial support for Revolution R, their distribution of R, which also includes components developed by the company. Major additional components include: ParallelR, the R Productivity Environment IDE, RevoScaleR (for big data analysis), RevoDeployR, web services framework, and the ability for reading and writing data in the SAS file format.[83] Revolution Analytics also offer a distribution of R designed to comply with established IQ/OQ/PQ criteria which enables clients in the pharmaceutical sector to validate their installation of REvolution R.[84] In 2015, Microsoft Corporation completed the acquisition of Revolution Analytics.[85] and has since integrated the R programming language into SQL Server 2016, SQL Server 2017, Power BI, Azure SQL Database, Azure Cortana Intelligence, Microsoft R Server and Visual Studio 2017.[86]

In October 2011, Oracle announced the Big Data Appliance, which integrates R, Apache Hadoop, Oracle Linux, and a NoSQL database with Exadata hardware.[87] As of 2012, Oracle R Enterprise[88] became one of two components of the "Oracle Advanced Analytics Option"[89] (alongside Oracle Data Mining).

IBM offers support for in-Hadoop execution of R,[90] and provides a programming model for massively parallel in-database analytics in R.[91]

Tibco offers a runtime-version R as a part of Spotfire.[92]

Mango offers a validation package for R, ValidR,[93][94] to make it compliant with drug approval agencies, like FDA. These agencies allow for the use of any statistical software in submissions, if only the software is validated, either by the vendor or sponsor itself.[95]

Examples

Basic syntax

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

In R, the generally preferred[96] assignment operator is an arrow made from two characters <-, although = can usually be used instead.[97]

[[INLINE_IMAGE|//upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Plots_from_lm_example.svg/540px-Plots_from_lm_example.svg.png|//upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Plots_from_lm_example.svg/810px-Plots_from_lm_example.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Plots_from_lm_example.svg/1080px-Plots_from_lm_example.svg.png 2x|Diagnostic plots from plotting “model” (q.v. “plot.lm()” function). Notice the mathematical notation allowed in labels (lower left plot).|h540|w540]]

Structure of a function

One of R’s strengths is the ease of creating new functions. Objects in the function body remain local to the function, and any data type may be returned.[98] Here is an example user-created function:

Mandelbrot set

Short R code calculating Mandelbrot set through the first 20 iterations of equation z = z2 + c plotted for different complex constants c. This example demonstrates:

  • use of community-developed external libraries (called packages), in this case caTools package

  • handling of complex numbers

  • multidimensional arrays of numbers used as basic data type, see variables C, Z and X.

[[INLINE_IMAGE|//upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Mandelbrot_Creation_Animation.gif/400px-Mandelbrot_Creation_Animation.gif|//upload.wikimedia.org/wikipedia/commons/a/a7/Mandelbrot_Creation_Animation.gif 1.5x|"Mandelbrot.gif" – graphics created in R with 14 lines of code in Example 2|h400|w400]]

See also

  • Comparison of numerical analysis software

  • Comparison of statistical packages

  • List of numerical analysis software

  • List of statistical packages

  • Rmetrics

  • RStudio

  • Statcheck

References

[1]
Citation Linkcran.r-project.orgHornik, Kurt (26 November 2015). "R FAQ". The Comprehensive R Archive Network. 2.1 What is R?. Retrieved 5 August 2018.
Sep 25, 2019, 12:32 AM
[2]
Citation Linkwww.stat.auckland.ac.nzIhaka, Ross (1998). R : Past and Future History (PDF) (Technical report). Statistics Department, The University of Auckland, Auckland, New Zealand.
Sep 25, 2019, 12:32 AM
[3]
Citation Linkcran.r-project.org"The Comprehensive R Archive Network". Retrieved 5 July 2019.
Sep 25, 2019, 12:32 AM
[4]
Citation Linkwww.r-project.org"R license". r-project. Retrieved 5 August 2018.
Sep 25, 2019, 12:32 AM
[5]
Citation Linkdocs.julialang.org"Introduction". The Julia Manual. Archived from the original on 20 June 2018. Retrieved 5 August 2018.
Sep 25, 2019, 12:32 AM
[6]
Citation Linkwww.r-project.orgR language and environment Hornik, Kurt (4 October 2017). "R FAQ". The Comprehensive R Archive Network. 2.1 What is R?. Retrieved 6 August 2018. R Foundation Hornik, Kurt (4 October 2017). "R FAQ". The Comprehensive R Archive Network. 2.13 What is the R Foundation?. Retrieved 6 August 2018. The R Core Team asks authors who use R in their data analysis to cite the software using: R Core Team (2016). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL http://www.R-project.org/.
Sep 25, 2019, 12:32 AM
[7]
Citation Linkwww.nytimes.comwidely used Fox, John & Andersen, Robert (January 2005). "Using the R Statistical Computing Environment to Teach Social Statistics Courses" (PDF). Department of Sociology, McMaster University. Retrieved 6 August 2018. Cite journal requires |journal= (help) Vance, Ashlee (6 January 2009). "Data Analysts Captivated by R's Power". New York Times. Retrieved 6 August 2018. R is also the name of a popular programming language used by a growing number of data analysts inside corporations and academia. It is becoming their lingua franca...
Sep 25, 2019, 12:32 AM
[8]
Citation Linkwww.nytimes.comVance, Ashlee (6 January 2009). "Data Analysts Captivated by R's Power". New York Times. Retrieved 6 August 2018. R is also the name of a popular programming language used by a growing number of data analysts inside corporations and academia. It is becoming their lingua franca...
Sep 25, 2019, 12:32 AM
[9]
Citation Link//doi.org/10.1038%2F517109aR's popularity David Smith (2012); R Tops Data Mining Software Poll, Java Developers Journal, May 31, 2012. Karl Rexer, Heather Allen, & Paul Gearan (2011); 2011 Data Miner Survey Summary, presented at Predictive Analytics World, Oct. 2011. Robert A. Muenchen (2012). "The Popularity of Data Analysis Software". Tippmann, Sylvia (29 December 2014). "Programming tools: Adventures with R". Nature. 517: 109–110. doi:10.1038/517109a.
Sep 25, 2019, 12:32 AM
[10]
Citation Linkwww.tiobe.com"TIOBE Index - The Software Quality Company". TIOBE. Retrieved 12 September 2019.
Sep 25, 2019, 12:32 AM
[11]
Citation Linkwww.r-project.orgGNU project "GNU R". Free Software Foundation (FSF) Free Software Directory. 23 April 2018. Retrieved 7 August 2018. R Project (n.d.). "What is R?". Retrieved 7 August 2018.
Sep 25, 2019, 12:32 AM
[12]
Citation Linklibrestats.com"Wrathematics" (27 August 2011). "How Much of R Is Written in R". librestats. Archived from the original on 12 June 2018. Retrieved 7 August 2018.
Sep 25, 2019, 12:32 AM
[13]
Citation Linkwww.linuxlinks.com"7 of the Best Free Graphical User Interfaces for R". linuxlinks.com. Retrieved 9 February 2016.
Sep 25, 2019, 12:32 AM
[14]
Citation Linkr-dir.com"List of R Editors". r-dir. Retrieved 7 August 2018.
Sep 25, 2019, 12:32 AM
[15]
Citation Linkr.cs.purdue.eduMorandat, Frances; Hill, Brandon; Osvald, Leo; Vitek, Jan (2012). "Evaluating the design of the R language: objects and functions for data analysis" (PDF). ECOOP'12 Proceedings of the 26th European conference on Object-Oriented Programming. Retrieved 17 May 2016.
Sep 25, 2019, 12:32 AM
[16]
Citation Linkwww.r-project.org"R: What is R?". R-Project. Retrieved 7 August 2018.
Sep 25, 2019, 12:32 AM
[17]
Citation Linkmyprofile.cos.comGentleman, Robert (9 December 2006). "Individual Expertise profile of Robert Gentleman". Archived from the original on 23 July 2011. Retrieved 20 July 2009.
Sep 25, 2019, 12:32 AM
[18]
Citation Link//doi.org/10.1111%2Fj.1740-9713.2018.01169.xThieme, Nick (August 2018). "R generation". Significance. 15 (4): 14–19. doi:10.1111/j.1740-9713.2018.01169.x.
Sep 25, 2019, 12:32 AM
[19]
Citation Linkcran.r-project.orgKurt Hornik. The R FAQ: Why R?. ISBN 3-900051-08-9. Retrieved 29 January 2008.
Sep 25, 2019, 12:32 AM
[20]
Citation Linkcran.r-project.org"R : Past and Future History -- A Free Software Project". cran.r-project.org. Retrieved 30 May 2016.
Sep 25, 2019, 12:32 AM