R was created by Rob Gentleman and Ross Ihaka in 1994; it is based on the S language developed at Bell Labs by John Chambers (Stanford Statistics).
It is an open-source language and environment for statistical computing and graphics.
Traditionally, academics and researchers. However, recently R has expanded also to industry and enterprise market. Worldwide usage on log-scale:
Source: http://pypl.github.io/PYPL.html
The PYPL Index is created by analyzing how often language tutorials are searched on Google (generated using raw data from Google Trends).
Pros:
Cons:
R is an interpreted language, i.e. programs do not need to be compiled into machine-language instructions.
R is object oriented, i.e. it can be extended to include non-standard data structures (objects). A generic function can act differently depending on what objects you passe to it.
R supports matrix arithmetics.
R packages can generate publication-quality plots, and interactive graphics.
Many user-created R packages contain implementations of cutting edge statistics methods.
As of September 29th 2018, there are 13,083 packages on CRAN, 1,560 on Bioconductor, and many others on github)
R in a nutshell and introductory book by Joseph Adler - R tutorial (https://www.tutorialspoint.com/r/r_packages.htm)
Advanced R book by Hadley Wickham for intermediate programmers (http://adv-r.had.co.nz/Introduction.html)
swirl
R-package for interactive learning for beginners (http://swirlstats.com/)
Data Camp
courses for data science, R, python and more (https://www.datacamp.com/courses)
R is open sources and cross platform (Linux, Mac, Windows).
To download it, go to the Comprehensive R Archive Network CRAN website. Download the latest version for your OS and follow the instructions.
Each year a new version of R is available, and 2-3 minor releases. You should update your software regularly.
The most popular R editors are:
We recommend to use RStudio, as it is more user-friendly.
RStudio is open-source and cross-platform (Linux, Mac, Windows).
Download and install the latest version for your OS from the official website.
More on RStudio cuztomization can be found here
R Script a text file containing R commands stored together.
R Markdown files can generate high quality reports contatining notes, code and code outputs. Python and bash code can also be executed.
R Notebook is an R Markdown document with chunks that can be executed independently and interactively, with output visible immediately beneath the input.
R presentation let’s you author slides that make use of R code and LaTeX equations as straightforward as possible.
R Sweave enables the embedding of R code within LaTeX documents.
Other documents
R packages are a collection of R functions, complied code and sample data.
They are stored under a directory called library in the R environment.
Some packages are installed by default during R installation and are always automatically loaded at the beginning of an R session.
# First, load Bioconductor script. You need to have an R version >=3.3.0.
source("https://bioconductor.org/biocLite.R")
# Then you can install packages with: biocLite("Package Name"), e.g.
biocLite("limma")
# You need to first install a package "devtools" from CRAN
install.packages("devtools")
# Load the "devtools" package
library(devtools)
# Then you can install a package from some user's reporsitory, e.g.
install_github("twitter/AnomalyDetection")
# or using install_git("url"), e.g.
install_git("https://github.com/twitter/AnomalyDetection")
## [1] "/Library/Frameworks/R.framework/Versions/4.0/Resources/library"
## Package LibPath Version
## abind "abind" "/Library/Frameworks/R.framework/Versions/4.0/Resources/library" "1.4-5"
## actuar "actuar" "/Library/Frameworks/R.framework/Versions/4.0/Resources/library" "3.1-1"
## additivityTests "additivityTests" "/Library/Frameworks/R.framework/Versions/4.0/Resources/library" "1.1-4"
## akima "akima" "/Library/Frameworks/R.framework/Versions/4.0/Resources/library" "0.6-2.1"
## ape "ape" "/Library/Frameworks/R.framework/Versions/4.0/Resources/library" "5.4-1"
## [1] ".GlobalEnv" "package:stats" "package:graphics" "package:grDevices" "package:utils" "package:datasets" "package:methods" "Autoloads" "package:base"
The swirl R package allows to learn R programming and data science very easily. You will use it in Lab 2, so here we are going to install it together. The workflow is the same as for any other R package.
Step 1: Open RStudio and type the following into the console:
That is just for this time!!! Once swirl is installed on your machine, you can skip directly to step 2.
Step 2: Start swirl
This is the only step that you will repeat every time you want to run swirl. First, you will load the package using the library() function. Then you will call the function that starts the magic! Type the following, pressing Enter after each line: