Paradigms | Multi-paradigm: procedural, object-oriented, functional, reflective, imperative, array [1] |
---|---|
Designed by | Ross Ihaka and Robert Gentleman |
Developer | R Core Team |
First appeared | August 1993 |
Stable release | |
Typing discipline | Dynamic |
Platform | arm64 and x86-64 |
License | GPL-2.0-or-later [3] |
Filename extensions | |
Website | www |
Influenced by | |
Influenced | |
Julia [7] pandas [8] | |
|
R is a programming language for statistical computing and data visualization. It has been adopted in the fields of data mining, bioinformatics and data analysis. [9]
The core R language is augmented by a large number of extension packages, containing reusable code, documentation, and sample data.
R software is open-source and free software. It is licensed by the GNU Project and available under the GNU General Public License. [3] It is written primarily in C, Fortran, and R itself. Precompiled executables are provided for various operating systems.
As an interpreted language, R has a native command line interface. Moreover, multiple third-party graphical user interfaces are available, such as RStudio—an integrated development environment—and Jupyter—a notebook interface.
R was started by professors Ross Ihaka and Robert Gentleman as a programming language to teach introductory statistics at the University of Auckland. [10] 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. [1]
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. [11] In August 1993, Ihaka and Gentleman posted a binary of R on StatLib — a data archive website. [12] At the same time, they announced the posting on the s-news mailing list. [13] On December 5, 1997, R became a GNU project when version 0.60 was released. [14] On February 29, 2000, the first official 1.0 version was released. [15]
R packages are collections of functions, documentation, and data that expand R. [16] For example, packages add report features such as RMarkdown, Quarto, [17] knitr and Sweave. Packages also add the capability to implement various statistical techniques such as linear, generalized linear and nonlinear modeling, classical statistical tests, spatial analysis, time-series analysis, and clustering. Easy package installation and use have contributed to the language's adoption in data science. [18]
Base packages are immediately available when starting R and provide the necessary syntax and commands for programming, computing, graphics production, basic arithmetic, and statistical functionality. [19]
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. [20] Its name and scope mimic the Comprehensive TeX Archive Network and the Comprehensive Perl Archive Network. [20] CRAN originally had three mirrors and 12 contributed packages. [21] As of 16 October 2024 [update] , it has 99 mirrors [22] and 21,513 contributed packages. [23] Packages are also available on repositories R-Forge, Omegahat, and GitHub. [24] [25] [26]
The Task Views on the CRAN web site list packages in fields such as 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.
The tidyverse package bundles several subsidiary packages that provide a common interface for tasks related to accessing and processing "tidy data", [27] data contained in a two-dimensional table with a single row for each observation and a single column for each variable. [28]
Installing a package occurs only once. For example, to install the tidyverse package: [28]
> install.packages("tidyverse")
To load the functions, data, and documentation of a package, one executes the library()
function. To load tidyverse: [a]
> # Package name can be enclosed in quotes> library("tidyverse")> # But also the package name can be called without quotes> library(tidyverse)
R comes installed with a command line console. Available for installation are various integrated development environments (IDE). IDEs for R include R.app [29] (OSX/macOS only), Rattle GUI, R Commander, RKWard, RStudio, and Tinn-R. [30]
General purpose IDEs that support R include Eclipse via the StatET plugin and Visual Studio via R Tools for Visual Studio.
Editors that support R include Emacs, Vim via the Nvim-R plugin, Kate, LyX via Sweave, WinEdt (website), and Jupyter (website).
Scripting languages that support R include Python (website), Perl (website), Ruby (source code), F# (website), and Julia (source code).
General purpose programming languages that support R include Java via the Rserve socket server, and .NET C# (website).
Statistical frameworks which use R in the background include Jamovi and JASP.
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 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 community hosts many conferences and in-person meetups. These groups include:
The main R implementation is written primarily in C, Fortran, and R itself. Other implementations include:
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. [33]
Although R is an open-source project, some companies provide commercial support:
> print("Hello, World!")[1] "Hello, World!"
The following examples illustrate the basic 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". [34] )
In R, the generally preferred assignment operator is an arrow made from two characters <-
, although =
can be used in some cases. [35]
> 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 ZA 2 6 12B 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 Zone 2 6 12two 20 30 42
One of R's strengths is the ease of creating new functions. [36] Objects in the function body remain local to the function, and any data type may be returned. In R, almost all functions and all user-defined functions are closures. [37]
Create a function:
# The input parameters are x and y.# The function returns a linear combination of x and y.f<-function(x,y){z<-3*x+4*y# an explicit return() statement is optional, could be replaced with simply `z`return(z)}
Usage output:
> 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
It is possible to define functions to be used as infix operators with 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 version 4.1.0 functions can be written in a short notation, which is useful for passing anonymous functions to higher-order functions: [38]
> sapply(1:5,\(i)i^2)# here \(i) is the same as function(i) [1] 1 4 9 16 25
In R version 4.1.0, a native pipe operator, |>
, was introduced. [39] This operator allows users to chain functions together one after another, instead of a nested function call.
> 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, in contrast to using the pipe character, is using intermediate objects. However, some argue that using the pipe operator will produce code that is easier to read. [28]
> mtcars_subset_rows<-subset(mtcars,cyl==4)> num_mtcars_subset<-nrow(mtcars_subset_rows)> print(num_mtcars_subset)[1] 11
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 by just setting a "class" attribute in each object. The latter is a Common Lisp Object System (CLOS)-like system of formal classes (also derived from S) and generic methods that supports multiple dispatch and multiple inheritance [40]
In the example, 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
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 valuesx<-1:6y<-x^2# Linear regression model y = A + B * xmodel<-lm(y~x)# Display an in-depth summary of the modelsummary(model)# Create a 2 by 2 layout for figurespar(mfrow=c(2,2))# Output diagnostic plots of the modelplot(model)
Output:
Residuals: 1 2 3 4 5 6 7 8 9 10 3.3333 -0.6667 -2.6667 -2.6667 -0.6667 3.3333Coefficients: 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 ‘ ’ 1Residual standard error: 3.055 on 4 degrees of freedomMultiple R-squared: 0.9583, Adjusted R-squared: 0.9478F-statistic: 91.88 on 1 and 4 DF, p-value: 0.000662
This Mandelbrot set example highlights the use of complex numbers. It models the first 20 iterations of the equation z = z2 + c
, where c
represents different complex constants.
Install the package that provides the write.gif()
function beforehand:
install.packages("caTools")
R Source code:
library(caTools)jet.colors<-colorRampPalette(c("green","pink","#007FFF","cyan","#7FFF7F","white","#FF7F00","red","#7F0000"))dx<-1500# define widthdy<-1400# define heightC<-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 numbersC<-matrix(C,dy,dx)# initialize output 3D arrayX<-array(0,c(dy,dx,20))Z<-0# loop with 20 iterationsfor (kin1:20){# the central difference equationZ<-Z^2+C# capture the resultsX[,,k]<-exp(-abs(Z))}write.gif(X,"Mandelbrot.gif",col=jet.colors,delay=100)
All R version releases from 2.14.0 onward have codenames that make reference to Peanuts comics and films. [41] [42] [43]
In 2018, core R developer Peter Dalgaard presented a history of R releases since 1997. [44] Some notable early releases before the named releases include:
The idea of naming R version releases was inspired by the Debian and 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-nut". [44]
Version | Release date | Name | Peanuts reference | Reference |
---|---|---|---|---|
4.4.1 | 2024-06-14 | Race for Your Life | [45] | [46] |
4.4.0 | 2024-04-24 | Puppy Cup | [47] | [48] |
4.3.3 | 2024-02-29 | Angel Food Cake | [49] | [50] |
4.3.2 | 2023-10-31 | Eye Holes | [51] | [52] |
4.3.1 | 2023-06-16 | Beagle Scouts | [53] | [54] |
4.3.0 | 2023-04-21 | Already Tomorrow | [55] [56] [57] | [58] |
4.2.3 | 2023-03-15 | Shortstop Beagle | [59] | [60] |
4.2.2 | 2022-10-31 | Innocent and Trusting | [61] | [62] |
4.2.1 | 2022-06-23 | Funny-Looking Kid | [63] [64] [65] [66] [67] [68] | [69] |
4.2.0 | 2022-04-22 | Vigorous Calisthenics | [70] | [71] |
4.1.3 | 2022-03-10 | One Push-Up | [70] | [72] |
4.1.2 | 2021-11-01 | Bird Hippie | [73] [74] | [72] |
4.1.1 | 2021-08-10 | Kick Things | [75] | [76] |
4.1.0 | 2021-05-18 | Camp Pontanezen | [77] | [78] |
4.0.5 | 2021-03-31 | Shake and Throw | [79] | [80] |
4.0.4 | 2021-02-15 | Lost Library Book | [81] [82] [83] | [84] |
4.0.3 | 2020-10-10 | Bunny-Wunnies Freak Out | [85] | [86] |
4.0.2 | 2020-06-22 | Taking Off Again | [87] | [88] |
4.0.1 | 2020-06-06 | See Things Now | [89] | [90] |
4.0.0 | 2020-04-24 | Arbor Day | [91] | [92] |
3.6.3 | 2020-02-29 | Holding the Windsock | [93] | [94] |
3.6.2 | 2019-12-12 | Dark and Stormy Night | See It was a dark and stormy night#Literature [95] | [96] |
3.6.1 | 2019-07-05 | Action of the Toes | [97] | [98] |
3.6.0 | 2019-04-26 | Planting of a Tree | [99] | [100] |
3.5.3 | 2019-03-11 | Great Truth | [101] | [102] |
3.5.2 | 2018-12-20 | Eggshell Igloos | [103] | [104] |
3.5.1 | 2018-07-02 | Feather Spray | [105] | [106] |
3.5.0 | 2018-04-23 | Joy in Playing | [107] | [108] |
3.4.4 | 2018-03-15 | Someone to Lean On | [109] [ better source needed ] | [110] |
3.4.3 | 2017-11-30 | Kite-Eating Tree | See Kite-Eating Tree [111] | [112] |
3.4.2 | 2017-09-28 | Short Summer | See It Was a Short Summer, Charlie Brown | [113] |
3.4.1 | 2017-06-30 | Single Candle | [114] | [115] |
3.4.0 | 2017-04-21 | You Stupid Darkness | [114] | [116] |
3.3.3 | 2017-03-06 | Another Canoe | [117] | [118] |
3.3.2 | 2016-10-31 | Sincere Pumpkin Patch | [119] | [120] |
3.3.1 | 2016-06-21 | Bug in Your Hair | [121] | [122] |
3.3.0 | 2016-05-03 | Supposedly Educational | [123] | [124] |
3.2.5 | 2016-04-11 | Very, Very Secure Dishes | [125] | [126] [127] [128] |
3.2.4 | 2016-03-11 | Very Secure Dishes | [125] | [129] |
3.2.3 | 2015-12-10 | Wooden Christmas-Tree | See A Charlie Brown Christmas [130] | [131] |
3.2.2 | 2015-08-14 | Fire Safety | [132] [133] | [134] |
3.2.1 | 2015-06-18 | World-Famous Astronaut | [135] | [136] |
3.2.0 | 2015-04-16 | Full of Ingredients | [137] | [138] |
3.1.3 | 2015-03-09 | Smooth Sidewalk | [139] [ page needed ] | [140] |
3.1.2 | 2014-10-31 | Pumpkin Helmet | See You're a Good Sport, Charlie Brown | [141] |
3.1.1 | 2014-07-10 | Sock it to Me | [142] [143] [144] [145] | [146] |
3.1.0 | 2014-04-10 | Spring Dance | [97] | [147] |
3.0.3 | 2014-03-06 | Warm Puppy | [148] | [149] |
3.0.2 | 2013-09-25 | Frisbee Sailing | [150] | [151] |
3.0.1 | 2013-05-16 | Good Sport | [152] | [153] |
3.0.0 | 2013-04-03 | Masked Marvel | [154] | [155] |
2.15.3 | 2013-03-01 | Security Blanket | [156] | [157] |
2.15.2 | 2012-10-26 | Trick or Treat | [158] | [159] |
2.15.1 | 2012-06-22 | Roasted Marshmallows | [160] | [161] |
2.15.0 | 2012-03-30 | Easter Beagle | [162] | [163] |
2.14.2 | 2012-02-29 | Gift-Getting Season | See It's the Easter Beagle, Charlie Brown [164] | [165] |
2.14.1 | 2011-12-22 | December Snowflakes | [166] | [167] |
2.14.0 | 2011-10-31 | Great Pumpkin | See It's the Great Pumpkin, Charlie Brown [168] | [169] |
r-devel | N/A | Unsuffered Consequences | [170] | [44] |
Charles Monroe "Sparky" Schulz was an American cartoonist, the creator of the comic strip Peanuts which features his two best-known characters, Charlie Brown and Snoopy. He is widely regarded as one of the most influential cartoonists in history, and cited by many cartoonists as a major influence, including Jim Davis, Murray Ball, Bill Watterson, Matt Groening, and Dav Pilkey.
Peanuts is a syndicated daily and Sunday American comic strip written and illustrated by Charles M. Schulz. The strip's original run extended from 1950 to 2000, continuing in reruns afterward. Peanuts is among the most popular and influential in the history of comic strips, with 17,897 strips published in all, making it "arguably the longest story ever told by one human being". At the time of Schulz's death in 2000, Peanuts ran in over 2,600 newspapers, with a readership of roughly 355 million across 75 countries, and had been translated into 21 languages. It helped to cement the four-panel gag strip as the standard in the United States, and together with its merchandise earned Schulz more than $1 billion. In 2015, a movie adaptation was released by Blue Sky Studios.
Charles "Charlie" Brown is the principal character of the comic strip Peanuts, syndicated in daily and Sunday newspapers in numerous countries all over the world. Depicted as a "lovable loser", Charlie Brown is one of the great American archetypes and a popular and widely recognized cartoon character. Charlie Brown is characterized as a person who frequently suffers, and as a result, is usually nervous and lacks self-confidence. He shows both pessimistic and optimistic attitudes: on some days, he is apprehensive to even get out of bed because he is unable to face the world, but on others, he hopes to accomplish things and is determined to do his best. Charlie Brown is easily recognized by his round head and trademark zigzag patterned shirt. His catchphrase is "Good Grief!"
Linus Van Pelt is a fictional character in Charles M. Schulz’s comic strip Peanuts. He is the best friend of Charlie Brown, the younger brother of Lucy Van Pelt, and the older brother of Rerun Van Pelt. His first appearance was on September 19, 1952, but he was not mentioned by name until three days later. He was first referred two months earlier, on July 14. Linus spoke his first words in 1954, the same year he was first shown with his security blanket. Linus is named after Schulz's friend Linus Maurer.
Peppermint Patty is a fictional character featured in Charles M. Schulz's comic strip Peanuts. Her full name, very rarely used in the strip, is Patricia Reichardt. She is one of a small group in the strip who live across town from Charlie Brown and his school friends. She has freckles and "mousy-blah" hair, and generally displays the characteristics of a tomboy. She made her first appearance on August 22, 1966. The following year she made her animated debut in the TV special You're in Love, Charlie Brown and began coaching a baseball team that played against Charlie Brown, and thereafter had other adventures with him. Uniquely, she refers to Charlie Brown and Lucy as "Chuck" and "Lucille", respectively. In most of her appearances, she is attracted to Charlie Brown, based on her reactions. Her birthday is October 4.
Lucille "Lucy" Van Pelt is a fictional character in the syndicated comic strip Peanuts, written and drawn by Charles Schulz. She is the older sister of Linus and Rerun. Lucy is characterized as a "fussbudget", crabby, bossy and opinionated girl who bullies most other characters in the strip, particularly Linus and Charlie Brown.
Violet Gray is a fictional character featured in the long-running syndicated daily and Sunday comic strip Peanuts, created by Charles M. Schulz. Violet first appeared in the February 7, 1951 strip. She was originally a major character, until she was eventually relegated to background and cameo appearances as other female characters became more prominent, with Lucy ultimately taking over most of Violet's character traits.
Woodstock is a fictional character in Charles M. Schulz's comic strip Peanuts. He is a small yellow bird of unknown species and Snoopy's best friend. The character first appeared in the March 4, 1966, strip, though he was not given a name until June 22, 1970. He is named after the Woodstock festival of 1969.
LAPACK is a standard software library for numerical linear algebra. It provides routines for solving systems of linear equations and linear least squares, eigenvalue problems, and singular value decomposition. It also includes routines to implement the associated matrix factorizations such as LU, QR, Cholesky and Schur decomposition. LAPACK was originally written in FORTRAN 77, but moved to Fortran 90 in version 3.2 (2008). The routines handle both real and complex matrices in both single and double precision. LAPACK relies on an underlying BLAS implementation to provide efficient and portable computational building blocks for its routines.
The Little Red-Haired Girl is an unseen character in the Peanuts comic strip by Charles M. Schulz, who serves as the object of Charlie Brown's affection, and a symbol of unrequited love. The character was first mentioned in the strip on November 19, 1961.
The Kite-Eating Tree is a fictional tree in the Peanuts comic strip created by Charles M. Schulz. In the comics, when Charlie Brown attempts to fly a kite, the kite always ends up tangled in the tree. In an editorial from 1964, the U.S. Catholic stated that Charlie Brown's encounters with the Kite-Eating Tree represent "defeat, but not capitulation" because Charlie Brown "refuses to concede that the impossible won’t someday happen—that he will manage to get the kite in the sky, where it belongs."
The Great Pumpkin is an unseen character in the comic strip Peanuts by Charles M. Schulz. According to Linus van Pelt, the Great Pumpkin is a legendary personality who rises from the pumpkin patch on Halloween carrying a large bag of toys to deliver to believing children. Linus continues to maintain faith in the Great Pumpkin, despite his friends' mockery and disbelief.
Notable events of 1952 in comics.
This is a list of adaptations in film, television, musical theater, and video games, based on characters from the Peanuts comic strip by Charles M. Schulz.
The following tables provide a comparison of numerical analysis software.
Nat Gertler is an American writer known for his comic books and his books about comics, including six on Charles Schulz's Peanuts. Gertler is the publisher of About Comics and founded an annual cartoonists' challenge, 24 Hour Comics Day. He has been nominated for three Eisner Awards and won one.
The Complete Peanuts is a series of books containing the entire run of Charles M. Schulz's long-running newspaper comic strip Peanuts, published by Fantagraphics Books. The series was published at a rate of two volumes per year, each containing two years of strips. Slipcased sets of two volumes are also available. The series comprises a total of 26 volumes, including a final volume that was a collection of Schulz strips, cartoons, stories, and illustrations that appeared outside of the daily newspaper strip. These hardcover books were first published between 2004 and 2016. Later, Fantagraphics also began publishing the series in a softcover format. A companion series titled Peanuts Every Sunday, collecting only the Sunday strips of the Peanuts series, was launched by Fantagraphics in 2013 and ran until late 2022.
Snoopy is an anthropomorphic beagle in the comic strip Peanuts by Charles M. Schulz. He also appears in all of the Peanuts films and television specials. Since his debut on October 4, 1950, Snoopy has become one of the most recognizable and iconic characters in the comic strip and is considered more famous than Charlie Brown in some countries. The original drawings of Snoopy were inspired by Spike, one of Schulz's childhood dogs.
PGF/TikZ is a pair of languages for producing vector graphics from a geometric/algebraic description, with standard features including the drawing of points, lines, arrows, paths, circles, ellipses and polygons. PGF is a lower-level language, while TikZ is a set of higher-level macros that use PGF. The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast with PSTricks, the PGF/TikZ graphics themselves are described in a language that resembles MetaPost. Till Tantau is the designer of the PGF and TikZ languages. He is also the main developer of the only known interpreter for PGF and TikZ, which is written in TeX. PGF is an acronym for "Portable Graphics Format". TikZ was introduced in version 0.95 of PGF, and it is a recursive acronym for "TikZ ist kein Zeichenprogramm".
Free statistical software is a practical alternative to commercial packages. Many of the free to use programs aim to be similar in function to commercial packages, in that they are general statistical packages that perform a variety of statistical analyses. Many other free to use programs were designed specifically for particular functions, like factor analysis, power analysis in sample size calculations, classification and regression trees, or analysis of missing data.
We set a goal of developing enough of a language to teach introductory statistics courses at Auckland.
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.