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-newsmailing 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]
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 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)
Statistical frameworks which use R in the background include Jamovi and JASP.
Community
The R Core Team was founded in 1997 to maintain the Rsource 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:
UseR!: an annual international R user conference (website)
Directions in Statistical Computing (DSC) (website)
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
Structure of a function
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)}
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
Native pipe operator
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:
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 sub-tasks which are saved into objects with meaningful names.[40] Here is an example with fewer than 10 lines that some readers may still struggle to grasp without intermediate named steps:
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[41]
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
Modeling and plotting
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
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)
Version names
All R version releases from 2.14.0 onward have codenames that make reference to Peanuts comics and films.[42][43][44]
In 2018, core R developer Peter Dalgaard presented a history of R releases since 1997.[45] Some notable early releases before the named releases include:
Version 1.0.0 released on February 29, 2000 (2000-02-29), a leap day
Version 2.0.0 released on October 4, 2004 (2004-10-04), "which at least had a nice ring to it"[45]
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".[45]
Wickham, Hadley; Çetinkaya-Rundel, Mine; Grolemund, Garrett (2023). R for data science: import, tidy, transform, visualize, and model data (2nd ed.). Beijing Boston Farnham Sebastopol Tokyo: O'Reilly. ISBN978-1-4920-9740-2.
^This displays to 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.
^ abHornik, Kurt; The R Core Team (12 April 2022). "R FAQ". The Comprehensive R Archive Network. 3.3 What are the differences between R and S?. Archived from the original on 28 December 2022. Retrieved 27 December 2022.
^Chambers, John M. (2020). "S, R, and Data Science". The R Journal. 12 (1): 462–476. doi:10.32614/RJ-2020-028. ISSN2073-4859. 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.
^Davies, Tilman M. (2016). "Installing R and Contributed Packages". The Book of R: A First Course in Programming and Statistics. San Francisco, California: No Starch Press. p. 739. ISBN9781593276515.
^Talbot, Justin; DeVito, Zachary; Hanrahan, Pat (1 January 2012). "Riposte: A trace-driven compiler and parallel VM for vector code in R". Proceedings of the 21st international conference on Parallel architectures and compilation techniques. ACM. pp. 43–52. doi:10.1145/2370816.2370825. ISBN9781450311823. S2CID1989369.
Upland area of the Pennines in Northern England Swaledale The Yorkshire Dales are a series of valleys, or dales, in the Pennines, a range of hills in England. They are mostly located in the ceremonial county of North Yorkshire, but extend into Cumbria and Lancashire; they were historically entirely within Yorkshire. The majority of the dales are within the Yorkshire Dales National Park, created in 1954.[1] The exception is the area around Nidderdale, which forms the separate Nidderdal...
Cosmological hierarchy of all matter and life For the song, see The Great Chain of Being (song). 1579 drawing of the Great Chain of Being from Didacus Valades [es], Rhetorica Christiana The great chain of being is a hierarchical structure of all matter and life, thought by medieval Christianity to have been decreed by God. The chain begins with God and descends through angels, humans, animals and plants to minerals.[1][2][3] The great chain of being (from&...
American theatre producer For the American academic architect, see Thomas L. Schumacher. Thomas SchumacherSchumacher speaking at the 2019 Tony AwardsPresident of Disney Theatrical GroupIncumbentAssumed office June 2001 (2001-06)Preceded byRon LoganPresident of Walt Disney Feature AnimationIn officeJanuary 1999 (1999-01) – 2002 (2002)Preceded byPeter SchneiderSucceeded byDavid Stainton Personal detailsBornThomas Hubbard Caswell Schumacher III (1957-12-05...
Berikut adalah Daftar Presiden Kepulauan Marshall. # Nama Gambar Awal Jabatan Akhir Jabatan Partai 1 Amata Kabua(1928-1996) 17 November 1979 20 Desember 1996 AKA / UDP — Kunio Lemari(Pejabat) 20 Desember 1996 14 Januari 1997 AKA / UDP 2 Imata Kabua(1943-2019) 14 Januari 1997 10 Januari 2000 AKA / UDP 3 Kessai Note(1950-) 10 Januari 2000 14 Januari 2008 AKA / UDP 4 Litokwa Tomeing(1939-) 14 Januari 2008 21 Oktober 2009 AKA / UDP — Ruben Zackhras(Pejabat) 21 Oktober 2009 2 November 2009 5 J...
The Peanut Butter FalconPoster filmSutradara Tyler Nilson Michael Schwartz Produser Albert Berger Christopher Lemole Lije Sarki David Thies Ron Yerxa Tim Zajaros Ditulis oleh Tyler Nilson Michael Schwartz Pemeran Shia LaBeouf Zack Gottsagen Dakota Johnson John Hawkes Bruce Dern Jon Bernthal Thomas Haden Church Penata musik Zachary Dawes Noam Pikelny Jonathan Sadoff Gabe Witcher SinematograferNigel BluckPenyunting Kevin Tent Nathaniel Fuller Perusahaanproduksi Armory Films Lucky Treehous...
Peta lokasi Lambang 55°30′N 25°36′E / 55.500°N 25.600°E / 55.500; 25.600 Utena (dengarkanⓘ, ialah sebuah kota di timur laut Lituania, pusat administratif distrik Utena dan kabupaten Utena. Terkenal akan pabrik birnya - Utenos alus. Penduduk 1990 - 35.200 2005 - 33.086 Pranala luar Halaman resmi Diarsipkan 2017-01-12 di Wayback Machine. Utena Diarsipkan 2007-05-27 di Wayback Machine. Artikel bertopik geografi atau tempat Lituania ini adalah sebuah rintisan. An...
2023 studio album by Conrad SewellPreciousStudio album by Conrad SewellReleased3 March 2023 (2023-03-03)Length54:22LabelSony Music AustraliaProducerConrad SewellJames GassRoderick KerrConrad Sewell chronology Life(2019) Precious(2023) Singles from Precious God Save the QueenReleased: 9 September 2022[1] Make Me a BelieverReleased: 14 October 2022 CarolineReleased: 11 November 2022 Rolling ThunderReleased: 12 December 2022[2][3] Ferris WheelReleas...
Kedutaan Besar Republik Indonesia di WellingtonEmbassy of the Republic of Indonesia in Wellington Koordinat41°17′18″S 174°45′47″E / 41.288409°S 174.76313°E / -41.288409; 174.76313Lokasi Wellington, Selandia BaruAlamat70 Glen Rd, KelburnWellington 6012, New ZealandDuta BesarFientje Maritje SuebuYurisdiksi Selandia Baru Kepulauan Cook Niue Samoa TongaSitus webkemlu.go.id/wellington/id Kedutaan Besar Republik Indonesia di Wellington (K...
Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Oktober 2022. Hari pertama sekolah adalah sebuah kegiatan belajar-mengajar antara guru dan siswa di sekolah dalam hari pertama sebuah tahun akademik. Kegiatan ini umumnya erat dikaitkan dengan Masa Orientasi Peserta Didik. Referensi Artikel bertopik pendidikan ini a...
لمعانٍ أخرى، طالع جريمة في قطار الشرق السريع (توضيح). جريمة في قطار الشرق السريعMurder on the Orient Express (بالإنجليزية) معلومات عامةالصنف الفني فيلم جريمةالمواضيع القائمة ... family relation (en) [1] — أسرة[1] — اختطاف[1] — محقق[1] — قتل عمد[1] — انتقام[1] تاريخ ال...
NCAA basketball team 2021–22 Notre Dame Fighting Irish men's basketballNCAA tournament, Second RoundConferenceAtlantic Coast ConferenceRecord24–11 (15–5 ACC)Head coachMike Brey (22nd season)Associate head coachAnthony SolomonAssistant coaches Ryan Humphrey Antoni Wyche Home arenaEdmund P. Joyce CenterSeasons← 2020–212022–23 → 2021–22 ACC men's basketball standings vte Conf Overall Team W L PCT W L PCT No. 9 Duke 16 &...
County in South Dakota, United States County in South DakotaBrown CountyCountyBrown County Courthouse in fall FlagLocation within the U.S. state of South DakotaSouth Dakota's location within the U.S.Coordinates: 45°36′N 98°21′W / 45.6°N 98.35°W / 45.6; -98.35Country United StatesState South DakotaFoundedJuly 6, 1881[1]SeatAberdeenLargest cityAberdeenArea • Total1,731 sq mi (4,480 km2) • Land1,713 sq&...
Cet article est une ébauche concernant la république démocratique du Congo. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Pour les articles homonymes, voir Lubule. Lubule la Lubule sur OpenStreetMap. Caractéristiques Bassin collecteur Congo Cours Confluence Luvwa Géographie Pays traversés République démocratique du Congo modifier La Lubule est une rivière du Haut-Katanga en république démocrat...
Апостолівський район ліквідована адміністративно-територіальна одиниця Герб Прапор Колишній район на карті Дніпропетровська область Основні дані Країна: СРСР ( УСРР), Україна Область: Дніпропетровська область Код КОАТУУ: 1220300000 Утворений: 1923 рік Ліквідований: 17 л�...
У этого термина существуют и другие значения, см. Доллар (значения). Доллар США[a] англ. US Dollar фр. Dollar des États-Unis[b] Коды и символы Коды ISO 4217 USD (840) Символы $ • US$ Территория обращения Страна-эмитент США Бермуды Бонайре Виргинские Острова (Великобр�...
Comisión de Derechos Humanos de la ONU Sede de la Comisión de Derechos Humanos de las Naciones Unidas en Ginebra, Suiza.Tipo Agencia especializada de la ONUForma legal InactivaFundación 12 de agosto de 1947Disolución 15 de marzo de 2006Sede central Ginebra, SuizaFiliales Consejo Económico y Social de las Naciones Unidas[editar datos en Wikidata] La Comisión de Derechos Humanos de las Naciones Unidas fue una comisión del Consejo Económico y Social (Ecosoc) y asistía en...
LGBT rights movement in Malta Malta LGBTIQ Rights MovementMGRM attending a 2023 environmental protestNamed afterMalta Gay Rights MovementFounded2001; 23 years ago (2001) (Malta)TypeLGBTIQ RightsHeadquartersMosta, MaltaLocationMosta, MaltaCo-CoordinatorCynthia ChircopCo-CoordinatorMohamed Ali (Dali) AguerbiAffiliationsILGA, ILGA-Europe, IGLYO, TGEU, AIDS Action Europe, NELFAWebsitewww.maltagayrights.org The Malta LGBTIQ Rights Movement (MGRM), previously known as the Malta Ga...
القديسغريغوريوس المستنير (بالأرمنية: Գրիգոր Լուսավորիչ) لوحة فسيفسائية للقديس غريغوريوس في كنيسة باماكاريستوس (جامع الفاتحية حاليًا)، إسطنبول معلومات شخصية الميلاد سنة 252 أرمينيا تاريخ الوفاة سنة 329 (76–77 سنة)[1] [2] تولى المنصب302 الحياة العم...
ألكسندر تشاكوفسكي معلومات شخصية الميلاد 26 أغسطس 1913(1913-08-26)سانت بطرسبرغ الوفاة 17 فبراير 1994 (80 سنة)موسكو مواطنة الاتحاد السوفيتي عضو في اتحاد الكتاب السوفيت، واللجنة المركزية للحزب الشيوعي السوفيتي الحياة العملية المدرسة الأم معهد مكسيم غوركي الأدبي المهنة صح�...
Warna hijau adalah pihak Sekutu (hijau terang adalah yang bergabung setelah penyerangan ke Pearl Harbor), Negara-negara Blok Poros berwarna biru dan warna abu-abu adalah negara netral. Bendera Jerman, Jepang, dan Italia dikibarkan berurutan di Kedubes Jepang di Tiergartenstraße, Berlin (September 1940).Dua pemimpin blok poros, yaitu Duce Benito Mussolini (Italia) dan Führer Adolf Hitler (Jerman).Perdana Menteri Jepang Hideki Tojo (tengah) bersama perwakilan pemerintah sesama Kawasan Kemakmu...