R Tutorial

R programming language is freely available in GNU General Public Licence, open source, powerful and highly extensible. R programming language is used heavily for Statistical computing and data analysis in data mining and is a favourite programming language for Data Scientist. R name was coined after its authors Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand. It was written in 1993. R software comes with in built packages of operators for calculations on arrays, lists, vectors and matrices. R is also used for Graphical representation of historical datasets.

Installation of R

Windows:

Download the R 3.3.1 version from its official website [r.project.org]  for 32/64 bits and install its respective bit versions based on your Windows OS bit. By default, the installer will install both the versions side by side. By default, all softwares are installed in C:\ProgramFiles directory. For R installation please create a directory as C:\R-3.3.1 while doing the installation to avoid messing up with protection mode of C:\ProgramFiles folder. Run the shortcut exe for R, this will open RGUI window for programming.

Sample Code:

> myString <- “Hi Amit”

> print(myString)

[1] “Hi Amit”

R Script File
All R programs are written and stored in a file called R Script file with an extension of .R

For example let’s say a R script first_program.R has below content
#First Program of R

myString <- “Hi! This is my first program”

print(myString);

save the file first_program.R and run it

In unix prompt as:

  • Rscript first_program.R

In Windows,

Go to RGUI –> File –> Open Script –> go to the folder where the script first_program.R is saved –> Select first_program.R –> Open –> Copy the code in first_program.R to RConsole –> Press Enter –> It will execute the code and display the output in the R Console.

Concepts of R
R-Reserved Key words R-Variables & Constants R-Datatypes
R-Operators R-Functions R-Loops
R-Vectors R-Matrices R-Strings
R-Lists R-Arrays R-Factors
R-Data Frames R-Packages R-Data Cleaning
R-Objects & Class R-Graphs & Charts R-Advanced Topics
Use of R Programming in Statistics
R-Mean R-Median R-Mode
R-Linear Regression R-Multiple Regression R-Poisson Regression
R-Logistic Regression R-Normal Distribution R-Binomial Distribution
R-Analysis of Covariance R-Time Series Analysis R-Nonlinear Least Square
R-Decision Tree R-Random Forest R-Survival Analysis
R-Chi Square Tests R-ARIMA Modelling R-Market Basket Analysis