R Programming
Language
Quick Tutorial
Agenda
Introduction
Data Types
Free Format Input
Simple Graphs
Agenda
Introduction
Data Types
Free Format Input
Simple Graphs
What is R
R is a free software programming language and
software environment for statistical computing
and graphics. (Wikipedia)
Download R
R is available for Windows, Linux and MacOS
Download it from:
http://www.r-project.org/
What R does and What it doesnt
Data handling and storage:
numeric, textual;
Matrix algebra;
Hash tables and regular
expressions;
High-level data analytic and
statistical functions
Classes (OO);
Graphics;
Programming language:
loops, branching, subroutines
Is not a database, but
connects to DBMSs;
Has no graphical user
interfaces, but connects to
Java, TclTk;
Language interpreter can be
very slow, but allows to call
own C/C++ code;
No spreadsheet view of data,
but connects to
Excel/MsOffice;
No commercial support
Agenda
Introduction
Data Types
Free Format Input
Simple Graphs
Data Types
Numeric:
Data Types (cont.)
Strings (character):
Data Types (cont.)
Vectors:
Data Types (cont.)
Matrices
Data Types (cont.)
Logical:
Data Types (cont.)
Factors:
Data Types (cont.)
Lists:
Data Types (cont.)
Data Frames:
Agenda
Introduction
Data Types
Free Format Input
Simple Graphs
Free Format Input
The function used to read data frames is
called: read.table()
R can read directly from the web. So, you
can specify the url of the dataset as input
Alternatively, you can specify the path to the
local file on your machine
Free Format Input
Agenda
Introduction
Data Types
Free Format Input
Simple Graphs
Simple Graphs
Useful Function
q(): quit R
getwd(), setwd(): get and set working
directory
help(functionName) or ?functionName
mean(), var(), cov(), cor(), summary() .. etc
Note: R depends on functions rather than
commands. So, the use of parenthesis is
crucial!
References
http://data.princeton.edu/R/introducingR.pdf
http://www.cyclismo.org/tutorial/R/index.html
http://www.statmethods.net/index.html
www.math.ntu.edu.
tw/~hchen/Prediction/notes/R-programming.ppt
http://en.wikipedia.org/wiki/R_
(programming_language)