An OPEN-SOURCE programming LANGUAGE and free software ENVIRONMENT for STATISTICAL COMPUTING and GRAPHICS
> R uses a ...
> command line interface |
"R doesn’t protect you from yourself: you can easily shoot yourself in the foot. As long as you don’t aim the gun at your foot and pull the trigger, you won’t have a problem."
R is a functional programming language. Every operation is a function call.
1 + 2 `+`(1, 2)
[1] 3 [1] 3
"To understand computations in R, two slogans are helpful:
- John Chambers
Don't reinvent the wheel!
R is highly extensible through packages
Many amazing packages come installed with R. See the Packages pane in RStudio or run the following command in the R console: installed.packages()
To access the functions (and other objects) from a package, first load the package using the library()
function.
qplot(x = Petal.Width, y = Petal.Length, data = iris)
Error: could not find function "qplot"
library(ggplot2) qplot(x = Petal.Width, y = Petal.Length, data = iris)
* Can also use the double-colon operator, for example:
ggplot2::qplot()
Most R functions come packaged with robust documentation, which you can access by using the help()
function:
# pull up help page for the mean function help(mean)
Fundamental unit of reproducible R code
Includes:
Standards for creating
May depend on other packages
Typically domain specific
The Comprehensive R Archive Network
A collection of sites ("mirrors") that carry identical material, consisting of the R distribution(s), the contributed extensions, documentation for R and binaries.
(i.e. main repository for R and packages)
Master site: https://CRAN.R-project.org/
Download the latest version of R
Over 7,800 packages available
Install packages from CRAN:
install.packages("dplyr")
Grammar for Data Manipulation