R & d là gì

Subtitles: Arabic, French, Portuguese [European], Chinese [Simplified], Italian, Portuguese [Brazilian], Vietnamese, Korean, German, Russian, English, Spanish, Japanese

Take control of your R and Python code

An integrated development environment for R and Python, with a console, syntax-highlighting editor that supports direct code execution, and tools for plotting, history, debugging and workspace management.

Easily share your insights

Share data products across your organization. One button deployment of Shiny applications, R Markdown reports, Jupyter Notebooks, and more.

Control and distribute packages

Control, organize, and govern your use of R packages to increase reproducibility and decrease the time you spend installing and troubleshooting.

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, R is used among data miners and statisticians for data analysis and developing statistical software. Users have created packages to augment the functions of the R language.

R

R terminal

ParadigmsMulti-paradigm: procedural, object-oriented, functional, reflective, imperative, array[1]Designed byRoss Ihaka and Robert GentlemanDeveloperR Core TeamFirst appearedAugust 1993; 28 years ago [1993-08]Stable release

4.1.2[2] / 1 November 2021; 4 months ago [1 November 2021]

Typing disciplineDynamicLicenseGNU GPL v2Filename extensions

  • .r[3]
  • .rdata
  • .rds
  • .rda[4]

Websitewww.r-project.org
Influenced by

  • Lisp
  • S
  • Scheme

InfluencedJulia[5]
  • R Programming at Wikibooks

According to surveys like Rexer's Annual Data Miner Survey and studies of scholarly literature databases, R is one of the most commonly used programming language used in data mining.[6][citation needed] As of February 2022,[update] R ranks 13th in the TIOBE index, a measure of programming language popularity.[7]

The official R software environment is an open-source free software environment within the GNU package, available under the GNU General Public License. It is written primarily in C, Fortran, and R itself [partially 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 combined with lexical scoping semantics from Scheme, which allow objects to be defined in predetermined blocks rather than the entirety of the code.[1] S was created by Rick Becker, John Chambers, Doug Dunn, Jean McRae, and Judy Schilling at Bell Labs around 1976. Designed for statistical analysis, the language is an interpreted language whose code could be directly run without a compiler.[8] Many programs written for S run unaltered in R.[9] As a dialect of the Lisp language, Scheme was created by Gerald J. Sussman and Guy L. Steele Jr. at MIT around 1975.[10]

In 1991, statisticians Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand, embarked on an S implementation.[11] It was named partly after the first names of the first two R authors and partly as a play on the name of S.[9] They began publicizing it on the data archive StatLib and the s-news mailing list in August 1993.[12] 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.[12][13][14] The first official release came in June 1995.[12] The first official "stable beta" version [v1.0] was released on 29 February 2000.[15][16]

The Comprehensive R Archive Network [CRAN] was officially announced on 23 April 1997. CRAN stores R's executable files, source code, documentations, as well as packages contributed by users. CRAN originally had 3 mirrors and 12 contributed packages.[17] As of January 2022, it has 101 mirrors[18] and 18,728 contributed packages.[19]

The R Core Team was formed in 1997 to further develop the language.[9] As of January 2022[update], 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, 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.[20] In April 2003,[21] the R Foundation was founded as a non-profit organization to provide further support for the R project.[9]

R's data structures include vectors, arrays, lists, and data frames.[22] Vectors are ordered collections of values and can be mapped to arrays of one or more dimensions in a column major order. That is, given an ordered collection of dimensions, one fills in values along the first dimension first, then fill in one-dimensional arrays across the second dimension, and so on.[23] R supports array arithmetics and in this regard is like languages such as APL and MATLAB.[22][24] The special case of an array with two dimensions is called a matrix. Lists serve as collections of objects that do not necessarily have the same data type. Data frames contain a list of vectors of the same length, plus a unique set of row names.[22] R has no scalar data type.[25] Instead, a scalar is represented as a length-one vector.[26]

R and its libraries implement various statistical techniques, including linear and nonlinear modeling, classical statistical tests, spatial and time-series analysis, classification, clustering, and others. For computationally intensive tasks, C, C++, and Fortran code can be linked and called at run time. Another of R's strengths is static graphics; it can produce publication-quality graphs that include mathematical symbols.[27]

Programming

R is an interpreted language; users can 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.

R supports procedural programming with functions and, for some functions, object-oriented programming with generic functions.[28] Due to its S heritage, R has stronger object-oriented programming facilities than most statistical computing languages.[citation needed] Extending it is facilitated by its lexical scoping rules, which are derived from Scheme.[29] R uses S-expressions to represent both data and code.[citation needed] R's extensible object system includes objects for [among others]: regression models, time-series and geo-spatial coordinates. Advanced users can write C, C++,[30] Java,[31] .NET[32] or Python code to manipulate R objects directly.[33]

Functions are first-class objects and can be manipulated in the same way as data objects, facilitating meta-programming that allows multiple dispatch. 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.[34] A generic function acts differently depending on the classes of the arguments passed to it. In other words, the generic function dispatches the method implementation specific to that object's class. For example, R has a generic print function that can print almost every class of object in R with print[objectname].[35] Many of R's standard functions are written in R,[citation needed] which makes it easy for users to follow the algorithmic choices made. R is highly extensible through the use of packages for specific functions and specific applications.

Main article: R package

R's capabilities are extended through user-created[36] 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.[37][38][39][40][41] 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.[42]

Multiple packages are included with the basic installation. Additional packages are available on CRAN,[18] Bioconductor, Omegahat,[43] GitHub, and other repositories.[44][45][46]

The "Task Views" on the CRAN website[47] 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 FDA as suitable for interpreting data from clinical research.[48] Microsoft maintains a daily snapshot of CRAN that dates back to Sept. 17, 2014.[49]

Other R package resources include R-Forge,[50] 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, cDNA microarray, and next-generation high-throughput sequencing methods.[51]

A group of packages called the Tidyverse, which can be considered a "dialect" of the R language, is increasingly popular among developers.[note 1] 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]. Dynamic and interactive graphics are available through additional packages.[52]

R is one of 5 languages with an Apache Spark API, along with Scala, Java, Python, and SQL.[53][54]

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

Release Date Description 0.16 0.49 0.60 0.65.1 1.0 1.4 1.8 2.0 2.1 2.6.2 2.11 2.12.2 2.13 2.14 2.15 3.0.0 3.3.3 3.4.0 3.5.0 3.6.0 4.0.0 4.1.0
This 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 1 April 1997.
1997-04-23 This is the oldest source release which is currently available on CRAN.[56] CRAN is started on this date, with 3 mirrors that initially hosted 12 packages.[57] Alpha versions of R for Microsoft Windows and the classic Mac OS are made available shortly after this version.[citation needed]
1997-12-05 R becomes an official part of the GNU Project. The code is hosted and maintained on CVS.
1999-10-07 First versions of update.packages and install.packages functions for downloading and installing packages from CRAN.[58]
2000-02-29 Considered by its developers stable enough for production use.[59]
2001-12-19 S4 methods are introduced and the first version for Mac OS X is made available soon after.
2003-10-08 Introduced a flexible condition handling mechanism for signalling and handling condition objects.
2004-10-04 Introduced lazy loading, which enables fast loading of data with minimal expense of system memory.
2005-04-18 Support for UTF-8 encoding, and the beginnings of internationalization and localization for different languages.
2008-02-08 Last version to support Windows 95, 98, Me and NT 4.0[60]
2010-04-22 Support for Windows 64-bit systems.
2011-02-25 Last version to support Windows 2000[61]
2011-04-14 Adding a new compiler function that allows speeding up functions by converting them to bytecode.
2011-10-31 Added mandatory namespaces for packages. Added a new parallel package.
2012-03-30 New load balancing functions. Improved serialisation speed for long vectors.
2013-04-03 Support for numeric index values 231 and larger on 64-bit systems.
2017-03-06 Last version to support Microsoft Windows XP.
2017-04-21 Just-in-time compilation [JIT] of functions and loops to byte-code enabled by default.
2018-04-23 Packages byte-compiled on installation by default. Compact internal representation of integer sequences. Added a new serialisation format to support compact internal representations.
2019-04-26 Improved sampling from a discrete uniform distribution, which was noticeably non-uniform on large populations.[62] New serialisation format supported since 3.5.0 becomes the default.
2020-04-24 R now uses a stringsAsFactors = FALSE default, and hence by default no longer converts strings to factors in calls to data.frame[] and read.table[]. Reference counting is used for tracking object sharing, which reduces the need for copying objects. New syntax for raw string constants.
2021-05-18 Introduced |> as the pipe operator for base R syntax [similar to the %>% operator of the magrittr package] and the anonymous function shortcut syntax \[x] x+1

Various applications can be used to edit or run R code.[63]

Early developers preferred to run R via the command line console,[64] succeeded by those who prefer an IDE.[65] IDEs for R include [in alphabetical order] Rattle GUI, R Commander, RKWard, RStudio, and Tinn-R.[64] R is also supported in multi-purpose IDEs such as Eclipse via the StatET plugin,[66] and Visual Studio via the R Tools for Visual Studio.[67] Of these, RStudio is the most commonly used.[65]

Editors that support R include Emacs, Vim [Nvim-R plugin],[68] Kate,[69] LyX,[70] Notepad++,[71] Visual Studio Code, WinEdt,[72] and Tinn-R.[73] Jupyter Notebook can also be configured to edit and run R code.[74]

R functionality is accessible from scripting languages including Python,[75] Perl,[76] Ruby,[77] F#,[78] and Julia.[79] Interfaces to other, high-level programming languages, like Java[80] and .NET C#[81][82] are available.

The main R implementation is written in R, C, and Fortran.[83] 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[84] are implementations of R in C++. Renjin, Riposte, and pqR attempt to improve performance by using multiple cores and deferred evaluation.[85] 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.[86]

Microsoft R Open [MRO] is a fully compatible R distribution with modifications for multi-threaded computations.[87][88] As of 30 June 2021, Microsoft started to phase out MRO in favor of the CRAN distribution. [89]

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

A growing number of R events bring users together, such as conferences [e.g. useR!, WhyR?, conectaR, SatRdays],[92][93] meetups,[94] as well as R-Ladies groups[95] that promote gender diversity. The R Foundation taskforce focuses on women and other under-represented groups.[96]

The official annual gathering of R users is called "useR!".[97] The first such event was useR! 2004 in May 2004, Vienna, Austria.[98] After skipping 2005, the useR! conference has been held annually, usually alternating between locations in Europe and North America.[99] History:[97]

  • useR! 2006, Vienna, Austria
  • useR! 2007, Ames, Iowa, US
  • useR! 2008, Dortmund, Germany
  • useR! 2009, Rennes, France
  • useR! 2010, Gaithersburg, Maryland, US
  • useR! 2011, Coventry, United Kingdom
  • useR! 2012, Nashville, Tennessee, US
  • useR! 2013, Albacete, Spain
  • useR! 2014, Los Angeles, California, US
  • useR! 2015, Aalborg, Denmark
  • useR! 2016, Stanford, California, US
  • 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

As of November 2021,[update] no next event date has been set yet. [100]

The R Journal is an open access, 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.

R is comparable to popular commercial statistical packages such as SAS, SPSS, and Stata. One difference is that R is available at no charge under a free software license.[101]

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.[102] 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".[103]

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

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.[105] Revolution Analytics offers an R distribution designed to comply with established IQ/OQ/PQ criteria that enables clients in the pharmaceutical sector to validate their installation of REvolution R.[106] In 2015, Microsoft Corporation acquired Revolution Analytics[107] 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.[108]

In October 2011, Oracle announced the Big Data Appliance, which integrates R, Apache Hadoop, Oracle Linux, and a NoSQL database with Exadata hardware.[109] As of 2012[update], Oracle R Enterprise[110] became one of two components of the "Oracle Advanced Analytics Option"[111] [alongside Oracle Data Mining].[citation needed]

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

TIBCO offers a runtime-version R as a part of Spotfire.[114]

Mango Solutions offers a validation package for R, ValidR,[115][116] 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.[117]

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".[118]]

In R, the generally preferred assignment operator is an arrow made from two characters x y print[y] # Print the vector’s contents. [1] 1 4 9 16 25 36 > z z # Return the contents of z to the current environment. [1] 2 6 12 20 30 42 > z_matrix 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 names[new_df] 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 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.[121] Example:

# Declare function “f” with parameters “x”, “y“ # that returns a linear combination of x and y. f 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.

 

Diagnostic plots from plotting “model” [q.v. “plot.lm[]” function]. Notice the mathematical notation allowed in labels [lower left plot].

> x y model summary[model] # Display an in-depth summary of the model. Call: lm[formula = y ~ x] Residuals: 1 2 3 4 5 6 7 8 9 10 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 = z2 + c plotted for different complex constants c. This example demonstrates:

 

"Mandelbrot.gif" – graphics created in R with 14 lines of code in Example 2

  • 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

Chủ Đề