1. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Introduction to R for Quantitative Research
Parthasarathi Edupally
CRISIL, GR & A
NBT@CRISIL, Nov 2014
2. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Outline
1. Motivation and Objective
What is this module about ?
Why learn R ?
3. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Outline
1. Motivation and Objective
What is this module about ?
Why learn R ?
2. Fundamentals
Language Foundations
Functions
Data
4. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Outline
1. Motivation and Objective
What is this module about ?
Why learn R ?
2. Fundamentals
Language Foundations
Functions
Data
3. Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional Programming
5. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Outline
1. Motivation and Objective
What is this module about ?
Why learn R ?
2. Fundamentals
Language Foundations
Functions
Data
3. Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional Programming
4. Further Reading and References
Advanced Topics
References
6. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Outline
1. Motivation and Objective
What is this module about ?
Why learn R ?
2. Fundamentals
Language Foundations
Functions
Data
3. Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional Programming
4. Further Reading and References
Advanced Topics
References
5. Thank You
7. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
What is this module about ?
8. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
What is this module about ?
An introduction to R statistical software - Just an Intro!
Understanding of language fundamentals than lot of
language specific details
9. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
What is this module about ?
An introduction to R statistical software - Just an Intro!
Understanding of language fundamentals than lot of
language specific details
Targeted people - Analysts with no formal software
background
10. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
What is this module about ?
An introduction to R statistical software - Just an Intro!
Understanding of language fundamentals than lot of
language specific details
Targeted people - Analysts with no formal software
background
Just to give a head start in learning and using R for analysis.
11. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Why learn R ?
12. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Why learn R ?
This is why you should :
Its open source, anyone can replicate your results
A massive set of packages for statistical analysis, machine
learning etc
Specially designed for statistics and Data analysis with
features like missing values, Dataframes, subsetting etc
13. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Why learn R ?
This is why you should :
Its open source, anyone can replicate your results
A massive set of packages for statistical analysis, machine
learning etc
Specially designed for statistics and Data analysis with
features like missing values, Dataframes, subsetting etc
Strong foundations in functional programming
Designed to connect to low level languages for high
performance
14. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Why learn R ?
This is why you should :
Its open source, anyone can replicate your results
A massive set of packages for statistical analysis, machine
learning etc
Specially designed for statistics and Data analysis with
features like missing values, Dataframes, subsetting etc
Strong foundations in functional programming
Designed to connect to low level languages for high
performance
Some drawbacks :
15. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Why learn R ?
This is why you should :
Its open source, anyone can replicate your results
A massive set of packages for statistical analysis, machine
learning etc
Specially designed for statistics and Data analysis with
features like missing values, Dataframes, subsetting etc
Strong foundations in functional programming
Designed to connect to low level languages for high
performance
Some drawbacks :
Most of the code is written in haste to solve a pressing
problem at hand, so code is less elegant, less faster and less
easier to understand.
It is not particularly fast programming language.
16. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Expressions
17. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Expressions
Most often when we write code we are writing an expression
Expression describes a computation and evaluates to a value
18. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Expressions
Most often when we write code we are writing an expression
Expression describes a computation and evaluates to a value
In Math - addition, division etc
All expressions can be represented by a function notation - It
is the most general representation
19. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Expressions
Most often when we write code we are writing an expression
Expression describes a computation and evaluates to a value
In Math - addition, division etc
All expressions can be represented by a function notation - It
is the most general representation
Types of expressions :
primitive expression – Numbers, Names, Strings
call expressions – operator(op1; op2)
20. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Expressions
Most often when we write code we are writing an expression
Expression describes a computation and evaluates to a value
In Math - addition, division etc
All expressions can be represented by a function notation - It
is the most general representation
Types of expressions :
primitive expression – Numbers, Names, Strings
call expressions – operator(op1; op2)
Demo
21. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Statements
22. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Statements
They are used to perform an action, they don’t evaluate to
value
23. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Statements
They are used to perform an action, they don’t evaluate to
value
There can be conditional and iterative statements
24. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Statements
They are used to perform an action, they don’t evaluate to
value
There can be conditional and iterative statements
Conditional statements:
if-elseif-else
25. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Statements
They are used to perform an action, they don’t evaluate to
value
There can be conditional and iterative statements
Conditional statements:
if-elseif-else
Iterative statements:
for() fg
while() fg
26. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Statements
They are used to perform an action, they don’t evaluate to
value
There can be conditional and iterative statements
Conditional statements:
if-elseif-else
Iterative statements:
for() fg
while() fg
Demo
27. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Environments
28. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Environments
They are used by the interpreter to understand the scoping
rules i.e., where to look for variables and functions by names
29. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Environments
They are used by the interpreter to understand the scoping
rules i.e., where to look for variables and functions by names
Job of an environment is to bind set of names to set of values
(a bag of names)
Each name points to an object stored elsewhere in memory
30. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Environments
They are used by the interpreter to understand the scoping
rules i.e., where to look for variables and functions by names
Job of an environment is to bind set of names to set of values
(a bag of names)
Each name points to an object stored elsewhere in memory
Developers mainly use them while writing packages to avoid
naming conflicts.
.
31. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Environments
They are used by the interpreter to understand the scoping
rules i.e., where to look for variables and functions by names
Job of an environment is to bind set of names to set of values
(a bag of names)
Each name points to an object stored elsewhere in memory
Developers mainly use them while writing packages to avoid
naming conflicts.
.
32. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
User-defined functions
33. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
User-defined functions
R is designed to support functional programming style. So
most of the computation we do will be a function call.
34. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
User-defined functions
R is designed to support functional programming style. So
most of the computation we do will be a function call.
Life cycle of user-defined function :
Function definition - name bound to that function in current
environment (enclosing environment)
Function call- A new environment(calling environment) is
created and call expression is executed
35. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
User-defined functions
R is designed to support functional programming style. So
most of the computation we do will be a function call.
Life cycle of user-defined function :
Function definition - name bound to that function in current
environment (enclosing environment)
Function call- A new environment(calling environment) is
created and call expression is executed
Please note there is execution environment, environment in
which function was called.
36. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
User-defined functions
R is designed to support functional programming style. So
most of the computation we do will be a function call.
Life cycle of user-defined function :
Function definition - name bound to that function in current
environment (enclosing environment)
Function call- A new environment(calling environment) is
created and call expression is executed
Please note there is execution environment, environment in
which function was called.
Demo
37. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Data Type
38. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Data Type
Every data will have a type associated with it. Basic types in
R are - Integer, Double, Character and factor.
39. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Data Type
Every data will have a type associated with it. Basic types in
R are - Integer, Double, Character and factor.
Native data types :
Have primitive expressions that evaluate to values of these
types
Built-in functions, operators, methods to manipulate those
values
40. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Data Type
Every data will have a type associated with it. Basic types in
R are - Integer, Double, Character and factor.
Native data types :
Have primitive expressions that evaluate to values of these
types
Built-in functions, operators, methods to manipulate those
values
We restrict data to be some number, vector or matrix with
values in them. But Data is much more general and powerful
than this.
Important idea in computer science is Code is also data. So
a piece of code which does square root computation is data
and can have type associated with it.
41. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Data Type
Every data will have a type associated with it. Basic types in
R are - Integer, Double, Character and factor.
Native data types :
Have primitive expressions that evaluate to values of these
types
Built-in functions, operators, methods to manipulate those
values
We restrict data to be some number, vector or matrix with
values in them. But Data is much more general and powerful
than this.
Important idea in computer science is Code is also data. So
a piece of code which does square root computation is data
and can have type associated with it.
These lead us to Abstract data types (Data structures), which
are based on the concept of objects.
42. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Objects
43. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Objects
Objects represent information - consist of data and
behaviour. So they are more powerful than just data.
44. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Objects
Objects represent information - consist of data and
behaviour. So they are more powerful than just data.
They can represent - things, properties, Interactions,
processes
45. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Objects
Objects represent information - consist of data and
behaviour. So they are more powerful than just data.
They can represent - things, properties, Interactions,
processes
Type of an object is called class
A class is some collection of methods(functions) and
behaviour conditions defined in it.
46. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Data structures
47. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Data structures
These are abstract data types defined in R and can be
organised according to their dimensionality and whether they
are homogeneous.
48. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Data structures
These are abstract data types defined in R and can be
organised according to their dimensionality and whether they
are homogeneous.
One dimensional structures - Atomic vectors, lists
Two dimensional structures - Matrices, Data frames
Multidimensional - Arrays
49. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Data structures
These are abstract data types defined in R and can be
organised according to their dimensionality and whether they
are homogeneous.
One dimensional structures - Atomic vectors, lists
Two dimensional structures - Matrices, Data frames
Multidimensional - Arrays
A data frame is the most common way of storing data in R,
and makes data analysis easier
50. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Data structures
These are abstract data types defined in R and can be
organised according to their dimensionality and whether they
are homogeneous.
One dimensional structures - Atomic vectors, lists
Two dimensional structures - Matrices, Data frames
Multidimensional - Arrays
A data frame is the most common way of storing data in R,
and makes data analysis easier Demo
51. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Simple Rules for efficiency
52. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Simple Rules for efficiency
Folder Structure : Always maintain a consistent folder
structure for all projects.
53. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Simple Rules for efficiency
Folder Structure : Always maintain a consistent folder
structure for all projects.
Naming: Give sensible names to files and variables
Always use comments to describe every line or group of
lines of code.
indentation : Follow consistent and creative indentations
while writing code.
54. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Simple Rules for efficiency
Folder Structure : Always maintain a consistent folder
structure for all projects.
Naming: Give sensible names to files and variables
Always use comments to describe every line or group of
lines of code.
indentation : Follow consistent and creative indentations
while writing code.
README : Draft README file in every folder. These have
to give brief description of files in the current folder.
55. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Subsetting
56. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Subsetting
Subsetting allows us to succinctly express complex
operations on large datasets.
They are very useful in data cleaning, which is first step in
data analysis.
It basically involves selecting and modifying specific
portions of data.
57. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Subsetting
Subsetting allows us to succinctly express complex
operations on large datasets.
They are very useful in data cleaning, which is first step in
data analysis.
It basically involves selecting and modifying specific
portions of data.
Subsetting Atomic vectors, lists, matrices, arrays and data
frames
58. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Subsetting
Subsetting allows us to succinctly express complex
operations on large datasets.
They are very useful in data cleaning, which is first step in
data analysis.
It basically involves selecting and modifying specific
portions of data.
Subsetting Atomic vectors, lists, matrices, arrays and data
frames Demo
59. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Functional Programming Paradigm
60. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Functional Programming Paradigm
R at heart is a functional programming language - gives tools
for creation and manipulation of functions.
61. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Functional Programming Paradigm
R at heart is a functional programming language - gives tools
for creation and manipulation of functions.
FP allows to write code clearly, concisely and at high level of
abstraction.
62. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Functional Programming Paradigm
R at heart is a functional programming language - gives tools
for creation and manipulation of functions.
FP allows to write code clearly, concisely and at high level of
abstraction.
It supports reusable software components.
Encourages the use of formal verification.
63. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Functional Programming Paradigm
R at heart is a functional programming language - gives tools
for creation and manipulation of functions.
FP allows to write code clearly, concisely and at high level of
abstraction.
It supports reusable software components.
Encourages the use of formal verification.
With latest trend of Multicore processors, FP is very
amenable to parallel programming.
64. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Important Advanced Topics
65. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Important Advanced Topics
Object systems in R
66. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Important Advanced Topics
Object systems in R
Basic Version Control with GitHub
67. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Important Advanced Topics
Object systems in R
Basic Version Control with GitHub
More Advanced Subsetting
68. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Important Advanced Topics
Object systems in R
Basic Version Control with GitHub
More Advanced Subsetting
Functional programming paradigm
69. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Important Advanced Topics
Object systems in R
Basic Version Control with GitHub
More Advanced Subsetting
Functional programming paradigm
Memory usage in R
70. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Important Advanced Topics
Object systems in R
Basic Version Control with GitHub
More Advanced Subsetting
Functional programming paradigm
Memory usage in R
Using lower level languages for better performance where
ever required in R
71. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Resources
72. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Resources
Advanced R by Hadley Wickham
73. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Resources
Advanced R by Hadley Wickham
Structure and Interpretation of Computer Programs - Berkley
webcast(CS61A, Fall 2013)
74. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
Resources
Advanced R by Hadley Wickham
Structure and Interpretation of Computer Programs - Berkley
webcast(CS61A, Fall 2013)
R package documentation
75. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
76. Introduction to
R for
Quantitative
Research
Parthasarathi
Edupally
Motivation and
Objective
What is this module
about ?
Why learn R ?
Fundamentals
Language Foundations
Functions
Data
Essentials
Basic Coding Etiquttes
Subsetting
Basic Functional
Programming
Further Reading
and References
Advanced Topics
References
Thank You
“To understand computations in R, two slogans are
helpful:
Everything that exists is an object.
Everything that happens is a function call.”
John Chambers (Inventor of R).