R is a programming language for statistical computing and graphics supported by the R Core Team and the R Foundation for Statistical Computing. Created by statisticians Ross Ihaka and Robert Gentleman (statistician), Robert Gentleman, R is used among Data mining, data miners and statisticians for developing statistical software and data analysis. Polls, Rexer's Annual Data Miner Survey, data mining surveys, and studies of scholarly literature databases show that R is highly popular; R ranks 11th in the TIOBE index, a measure of programming language popularity. The official R software environment is an open-source free software environment within the List of GNU packages, GNU package, available under the GNU General Public License. It is written primarily in C (programming language), C, Fortran, and R itself (partially Self-hosting (compilers), self-hosting). Precompiled executables are provided for various operating systems. R has a command line interface. Multiple third-party graphical user interfaces are also available, such as RStudio, an integrated development environment, and Jupyter, a notebook interface.


R is an open-source implementation of the S (programming language), S programming language combined with lexical scoping semantics from Scheme (programming language), Scheme, which allow objects to be defined in predetermined blocks rather than the entirety of the code. S was created by Rick Becker, John Chambers (programmer), John Chambers, Doug Dunn, Jean McRae, and Judy Schilling at Bell Laboratories, Bell Labs around 1976. Many codes written for S run unaltered in R. Scheme was created by computer scientists Gerald Jay Sussman, Gerald J. Sussman and Guy L. Steele Jr. at Massachusetts Institute of Technology, MIT around 1975. In 1991, statisticians Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand, embarked on an S implementation. It was named partly after the first names of the first two R authors and partly as a play on the name of S. They began publicizing it on the data archive StatLib and the ''s-news'' mailing list in August 1993. In 1995, statistician Martin Mächler convinced Ihaka and Gentleman to make R a free and open-source software under the GNU General Public License. The first official release came in June 1995. The Comprehensive R Archive Network (CRAN) was officially announced on 23 April 1997 with 3 mirrors and 12 contributed packages. The R Core Team was formed in 1997 to further develop the language. , it consists of Chambers, Gentleman, Ihaka, and Mächler, plus statisticians Douglas Bates, Peter Dalgaard, Kurt Hornik, Michael Lawrence, Friedrich Leisch, Uwe Ligges, Thomas Lumley (statistician), Thomas Lumley, Sebastian Meyer, Paul Murrell, Martyn Plummer, Brian Ripley, Deepayan Sarkar, Duncan Temple Lang, Luke Tierney, and Simon Urbanek, as well as computer scientist Tomas Kalibera. Stefano Iacus, Guido Masarotto, Heiner Schwarte, Seth Falcon, Martin Morgan, and Duncan Murdoch were members. The first official Software release life cycle#BETA, "stable beta" version (v1.0) was released on 29 February 2000. In April 2003, the R Foundation was founded as a non-profit organization to provide further support for the R project.



R and its libraries implement various statistical and graphical techniques, including linear and nonlinear modeling, classical statistical tests, spatial analysis, spatial and time-series analysis, classification, clustering, and others. R is easily extensible through functions and extensions, and its community is noted for contributing packages. Many of R's standard functions are written in R, which makes it easy for users to follow the algorithmic choices made. For computationally intensive tasks, C (programming language), C, C++, and Fortran code can be Linking (computing), linked and called at run time. Advanced users can write C, C++, Java (programming language), Java, .NET Framework, .NET or Python (programming language), Python code to manipulate R objects directly. R is highly extensible through the use of packages for specific functions and specific applications. Due to its S (programming language), S heritage, R has stronger object-oriented programming facilities than most statistical computing languages. Extending it is facilitated by its lexical scoping rules. Another of R's strengths is static graphics; it can produce publication-quality graphs that include mathematical symbols. Dynamic and interactive graphics are available through additional packages.


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. Like languages such as APL (programming language), APL and MATLAB, R supports Matrix (mathematics), matrix arithmetic. R's data structures include Column vector, vectors, Matrix (mathematics), matrices, arrays, data frames (similar to Table (database), tables in a relational database) and List (computing), lists. Arrays are stored in column-major order. R's extensible object system includes objects for (among others): Regression analysis, regression models, time-series and Spatial analysis, geo-spatial coordinates. R has no scalar data type. Instead, a scalar is represented as a length-one vector. Many features of R derive from Scheme (programming language), Scheme. R uses S-expressions to represent both data and code. Functions are first-class functions, first-class objects and can be manipulated in the same way as data objects, facilitating meta-programming that allows multiple dispatch. Variables in R are lexical scope, lexically scoped and dynamic typing, dynamically typed. Function arguments are passed by value, and are lazy evaluation, lazy—that is to say, they are only evaluated when they are used, not when the function is called. R supports procedural programming with Function (computer science), functions and, for some functions, object-oriented programming with generic functions. A generic function acts differently depending on the Class (computer programming), classes of the arguments passed to it. In other words, the generic function Dynamic dispatch, dispatches the Method (computer science), method implementation specific to that object's Class (computer programming), class. For example, R has a Generic function, generic print function that can print almost every Class (computer programming), class of Object (computer science), object in R with print(objectname) Although used mainly by statisticians and other practitioners seeking an environment for statistical computation and software development, R can also operate as a numerical linear algebra, general matrix calculation toolbox – with performance benchmarks comparable to GNU Octave or MATLAB.


R's capabilities are extended through user-created ''packages'', which offer statistical techniques, graphical devices, import/export, reporting (RMarkdown, knitr, Sweave), etc. R's packages and the ease of installing and using them, has been cited as driving the language's widespread adoption in data science. The 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 archiving. Multiple packages are included with the basic installation. more than 15,000 additional packages were available at the R package, Comprehensive R Archive Network (CRAN), Bioconductor, Omegahat, GitHub, and other repositories. The "Task Views" on the CRAN website lists packages in fields including Finance, Genetics, High Performance Computing, Machine Learning, Medical Imaging, Social Sciences and Spatial Statistics. R has been identified by the Food and Drug Administration, FDA as suitable for interpreting data from clinical research. Microsoft maintains a daily snapshot of CRAN that dates back to Sept. 17, 2014. Other R package resources include R-Forge, a platform for the collaborative development of R packages. The Bioconductor project provides packages for genomic data analysis, including object-oriented data-handling and analysis tools for data from Affymetrix, Complementary DNA, cDNA microarray, and next-generation high-throughput sequencing methods. A group of packages called the Tidyverse, which can be considered a "dialect" of the R language, is increasingly popular among developers.Metacran
listed 7 of the 8 core packages of the Tidyverse in the list of most download R packages.
It 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). R is one of 5 languages with an Apache Spark API, along with Scala (programming language), Scala, Java (programming language), Java, Python (programming language), Python, and SQL.


A list of changes in R releases is maintained in various "news" files at CRAN.Changes in versions 3.0.0 onward: Earlier change logs (by major release number): * * * * * Some highlights are listed below for several major releases.


Various applications can be used to edit or run R code. Early developers preferred to run R via the command line console, succeeded by those who prefer an Integrated development environment, IDE. IDEs for R include (in alphabetical order) Rattle GUI, R Commander, RKWard, RStudio, and Tinn-R. R is also supported in multi-purpose IDEs such as Eclipse (software), Eclipse via the StatET plugin, and Microsoft Visual Studio, Visual Studio via the R Tools for Visual Studio. Of these, Rstudio is the most commonly used. Editors that support R include Emacs Speaks Statistics, Emacs, Vim (text editor), Vim (Nvim-R plugin), Kate (text editor), Kate, LyX, Notepad++, Visual Studio Code, WinEdt, and Tinn-R. Jupyter, Jupyter Notebook can also be configured to edit and run R code. R functionality is accessible from scripting languages including Python (programming language), Python, Perl, Ruby (programming language), Ruby, F Sharp (programming language), F#, and Julia (programming language), Julia. Interfaces to other, high-level programming languages, like Java (programming language), Java and C Sharp (programming language), .NET C# are available.


The main R implementation is written in R, C, and Fortran. 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 an
are Java (programming language), Java implementations of R for use in a Java virtual machine, Java Virtual Machine. CXXR, rho, and Riposte are implementations of R in C++. Renjin, Riposte, and pqR attempt to improve performance by using multiple cores and deferred evaluation. 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 Software, TIBCO built a runtime engine called TERR, which is part of Spotfire. Microsoft R Open (MRO) is a fully compatible R distribution with modifications for multi-threaded computations. As of 30 June 2021, Microsoft started to phase out MRO in favor of the CRAN distribution.


R has local communities worldwide for users to network, share ideas, and learn. A growing number of R events bring users together, such as conferences (e.g. #useR! conferences, useR!, WhyR?, conectaR, SatRdays), meetups, as well as R-Ladies Global, R-Ladies groups that promote gender diversity. The R Foundation taskforce focuses on women and other under-represented groups.

useR! conferences

The official annual gathering of R users is called "useR!". The first such event was useR! 2004 in May 2004, Vienna, Austria. After skipping 2005, the useR! conference has been held annually, usually alternating between locations in Europe and North America. History: * 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 * useR! 2020, took place online due to COVID-19 pandemic * useR! 2021, took place online due to COVID-19 pandemic no next event date has been set yet.

''The R Journal''

''The R Journal'' is an open access, Academic journal, refereed journal of the R project. 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 alternatives

R is comparable to popular commercial statistical packages such as SAS (software), SAS, SPSS, and Stata. One difference is that R is available at no charge under a free software license. 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. 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". R is more procedural than either SAS or SPSS, both of which make heavy use of pre-programmed procedures (called "procs") that are built-in to the language environment and customized by parameters of each call. R generally processes data in-memory, which limits its usefulness in processing larger files.

Commercial support

Although R is an open-source project, some companies provide commercial support and extensions. 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 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.Morgan, Timothy Prickett (2011-02-07). "'Red Hat for stats' goes toe-to-toe with SAS". The Register, 7 February 2011. Retrieved from https://www.theregister.co.uk/2011/02/07/revolution_r_sas_challenge/. Revolution Analytics offers an R distribution designed to comply with established Verification and validation, IQ/OQ/PQ criteria that enables clients in the pharmaceutical sector to validate their installation of REvolution R. In 2015, Microsoft Corporation acquired Revolution Analytics and integrated the R programming language into SQL Server, Power BI, Azure SQL Managed Instance, Azure Cortana Intelligence, Microsoft ML Server and Visual Studio 2017. In October 2011, Oracle Corporation, Oracle announced the ''Big Data Appliance'', which integrates R, Apache Hadoop, Oracle Linux, and a NoSQL database with Exadata hardware. , Oracle R EnterpriseChris Kanaracus (2012)
''Oracle Stakes Claim in R With Advanced Analytics Launch''
PC World, February 8, 2012.
became one of two components of the "Oracle Advanced Analytics Option"Doug Henschen (2012)
''Oracle Stakes Claim in R With Advanced Analytics Launch''
InformationWeek, April 4, 2012.
(alongside Oracle Data Mining). IBM offers support for in-Hadoop execution of R, and provides a programming model for massively parallel in-database analytics in R. Tibco Software, TIBCO offers a runtime-version R as a part of Spotfire. Mango Solutions offers a validation package for R, ValidR, to comply with drug approval agencies, such as the FDA. These agencies required the use of validated software, as attested by the vendor or sponsor.


Basic syntax

The following examples illustrate the basic programming language syntax, syntax of the language and use of the command-line interface. (An expanded list of standard language features can be found in the R manual, "An Introduction to R".) In R, the generally preferred Assignment (computer science), assignment operator is an arrow made from two characters <-, although = can be used in some cases. > x <- 1:6 # Create a numeric vector in the current environment > y <- x^2 # Create 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 turns 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 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 data.frame 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. > 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 data.frame column Z can be accessed using $Z, ['Z'], or [3] syntax, and the values are the same. [1] TRUE > attributes(new_df) # Print attributes information about the new_df object $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; can also be done using rownames() > new_df X Y Z one 2 6 12 two 20 30 42

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. Example: # Declare function “f” with parameters “x”, “y“ # that returns a linear combination of x and y. f <- function(x, y) > f(1, 2) [1] 11 > f(c(1,2,3), c(5,3,4)) [1] 23 18 25 > f(1:3, 4) [1] 19 22 25

Modeling and plotting

The R language has built-in support for data modeling and graphics. The following example shows how R can easily generate and plot a linear model with residuals. > x <- 1:6 # Create x and y values > y <- x^2 > model <- lm(y ~ x) # Linear regression model y = A + B * x. > summary(model) # Display an in-depth summary of the model. Call: lm(formula = y ~ x) Residuals: 1 2 3 4 5 6 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 > par(mfrow = c(2, 2)) # Create a 2 by 2 layout for figures. > plot(model) # Output diagnostic plots of the model.

Mandelbrot set

Short R code calculating Mandelbrot set through the first 20 iterations of equation ''z'' = ''z''2 + ''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. install.packages("caTools") # install external package library(caTools) # external package providing write.gif function jet.colors <- colorRampPalette(c("red", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow", "#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), dx)) C <- matrix(C, dy, dx) # reshape as square matrix of complex numbers Z <- 0 # initialize Z to zero X <- array(0, c(dy, dx, 20)) # initialize output 3D array for (k in 1:20) write.gif(X, "Mandelbrot.gif", col = jet.colors, delay = 100)

See also

* S (programming language), S programming language * R package * Comparison of numerical-analysis software * Comparison of statistical packages * List of numerical-analysis software * List of statistical software * Rmetrics * RStudio * Tidyverse



External links

* of the R project
R Technical Papers
{{Portal bar, Computer programming R (programming language), Array programming languages Cross-platform free software Data mining and machine learning software Data-centric programming languages Dynamically typed programming languages Free plotting software Free statistical software Functional languages GNU Project software Literate programming Numerical analysis software for Linux Numerical analysis software for MacOS Numerical analysis software for Windows Programming languages created in 1993 Science software Statistical programming languages Articles with example R code