SlideShare a Scribd company logo
R Data Structures
(Pt. III)
WMG Training
Nov 2016
National Environmental Standards and Regulations Enforcement Agency
(NESREA)
Facilitator: Victor Ordu
Types of Data Structures
1. Vectors
2. Data frames
3. Matrices
4. Lists
5. Arrays
Matrices
• Like data frame are 2-dimensional
– rows & columns
• Like vectors, only of particular type
– integer, character, numeric, logical, etc.
• Can be built using matrix()
• Others include rbind(), cbind()
• Matrix arithmetic possible in R but not our
focus
• Matrix creation is also useful in other
operations such as drawing multiple plots
• Exploring a matrix is somewhat similar to that
of a data frame
– dim()
– typeof()
– class()
• Download and run the script
create-matrix.R to make a matrix, mat
Note: Save the script from your browser as a .R file
Indexing
• This is a crucial aspect of R programming
• Enable you to get or set elements of a data
structure
• Bracket operator “[ ]” is used for indexing
– For vectors: [ ]
– For matrices & data frames: [ , ]
– For lists: [ ] and [[ ]]
• The format for indexing is [row, column]
– [1, 2] means “first row, second column”
• This notation is like mapping the location of an
element in a 2-dimensional data structure.
• If you want to get a matrix value on the 4th
row and the 3rd column, you run:
matrix[4, 3]
• If you want to change a matrix value on the 4th
row and the 3rd column, you run:
matrix[4, 3] <- <new value>
• Ranges also work well with indexing
– First 3 rows of column 2 is written as [1:3, 2]
– Row 4 of columns 2 to 4 is coded as [4, 2:4]
• Note the indices (or is it indexes?) of the
matrix along the margins of the output
(also, learn that there is no trivial or frivolous
output in R. Studying it can teach you a lot!)
• Nit-picking is also possible
– To select rows 2 & 4 of columns 3 & 5 write
[c(2, 4), c(3, 5)] # select with c()
• An empty value means ‘ALL’
– E.g. [, 5] (means ‘all rows in column 5’)
• Negative indexing is there too!
– Row 2 except column 5 is written as [2, -5]
Indexing is for vectors too!
• Bracket notation applies to vectors
• Because they have 1 dimension, there will be
no comma inside the brackets
i.e. [ ] and not [ , ]
• Try it out!
Homogenous Heterogeneous
1-dimension Atomic vectors Lists
2-dimensions Matrices Data frames
N-dimensions Arrays

More Related Content

What's hot

Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.
Education Front
 
Data Structure # vpmp polytechnic
Data Structure # vpmp polytechnicData Structure # vpmp polytechnic
Data Structure # vpmp polytechnic
lavparmar007
 
Pandas
PandasPandas
Arrays declartion and initialization
Arrays declartion and initializationArrays declartion and initialization
Arrays declartion and initialization
sangrampatil81
 
Arrays in C
Arrays in CArrays in C
Arrays in C
sangrampatil81
 
Introduction to Data Structure part 1
Introduction to Data Structure part 1Introduction to Data Structure part 1
Introduction to Data Structure part 1
ProfSonaliGholveDoif
 
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHIBCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
Sowmya Jyothi
 
Introduction of data structures and algorithms
Introduction of data structures and algorithmsIntroduction of data structures and algorithms
Introduction of data structures and algorithms
VinayKumarV16
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
Files and data storage
Files and data storageFiles and data storage
Files and data storage
Zaid Shabbir
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
Rohit Rai
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
Vivek Kumar Sinha
 
Types Of Data Structure
Types Of Data StructureTypes Of Data Structure
Types Of Data Structure
Vaishali Chinchkhede
 
Ii pu cs practical viva voce questions
Ii pu cs  practical viva voce questionsIi pu cs  practical viva voce questions
Ii pu cs practical viva voce questions
Prof. Dr. K. Adisesha
 
Data Structures - Lecture 2 [Introduction to Data Structures]
Data Structures - Lecture 2 [Introduction to Data Structures]Data Structures - Lecture 2 [Introduction to Data Structures]
Data Structures - Lecture 2 [Introduction to Data Structures]
Muhammad Hammad Waseem
 
Rdbms
RdbmsRdbms
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
Transweb Global Inc
 
Data Structures
Data StructuresData Structures
Data Structures
Prof. Dr. K. Adisesha
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
Aakash deep Singhal
 
How to handling strings in r
How to handling strings in rHow to handling strings in r
How to handling strings in r
Pramod Rathore
 

What's hot (20)

Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.
 
Data Structure # vpmp polytechnic
Data Structure # vpmp polytechnicData Structure # vpmp polytechnic
Data Structure # vpmp polytechnic
 
Pandas
PandasPandas
Pandas
 
Arrays declartion and initialization
Arrays declartion and initializationArrays declartion and initialization
Arrays declartion and initialization
 
Arrays in C
Arrays in CArrays in C
Arrays in C
 
Introduction to Data Structure part 1
Introduction to Data Structure part 1Introduction to Data Structure part 1
Introduction to Data Structure part 1
 
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHIBCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
 
Introduction of data structures and algorithms
Introduction of data structures and algorithmsIntroduction of data structures and algorithms
Introduction of data structures and algorithms
 
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHIBCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES SEARCHING AND SORTING MRS.SOWMYA JYOTHI
 
Files and data storage
Files and data storageFiles and data storage
Files and data storage
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Types Of Data Structure
Types Of Data StructureTypes Of Data Structure
Types Of Data Structure
 
Ii pu cs practical viva voce questions
Ii pu cs  practical viva voce questionsIi pu cs  practical viva voce questions
Ii pu cs practical viva voce questions
 
Data Structures - Lecture 2 [Introduction to Data Structures]
Data Structures - Lecture 2 [Introduction to Data Structures]Data Structures - Lecture 2 [Introduction to Data Structures]
Data Structures - Lecture 2 [Introduction to Data Structures]
 
Rdbms
RdbmsRdbms
Rdbms
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
 
Data Structures
Data StructuresData Structures
Data Structures
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
 
How to handling strings in r
How to handling strings in rHow to handling strings in r
How to handling strings in r
 

Viewers also liked

Juan jesús vite serrano
Juan jesús vite serranoJuan jesús vite serrano
Juan jesús vite serrano
chuchinjuan
 
Microsoft word mayo
Microsoft word   mayo Microsoft word   mayo
Microsoft word mayo
Proceso Jinamar
 
Emprendimiento
EmprendimientoEmprendimiento
Emprendimiento
mariacamilasepulvedacsj
 
Redes de valor y calidad
Redes de valor y calidadRedes de valor y calidad
Redes de valor y calidad
mariacamilasepulvedacsj
 
Maria camila sepulveda 7a
Maria camila sepulveda 7aMaria camila sepulveda 7a
Maria camila sepulveda 7a
mariacamilasepulvedacsj
 
Trabajo 7 a
Trabajo 7 aTrabajo 7 a
Programa pdf
Programa pdfPrograma pdf
Programa pdf
Proceso Jinamar
 
Geometria consulta terminos no defeinidos
Geometria consulta terminos no defeinidosGeometria consulta terminos no defeinidos
Geometria consulta terminos no defeinidos
Alejandro Cadena Bonilla
 
Monica rojas
Monica rojasMonica rojas
Monica rojas
madelin araujo
 
Saberes previos
Saberes previosSaberes previos
Saberes previos
mariacamilasepulvedacsj
 
Libreto info up 2012 2013
Libreto info up 2012 2013Libreto info up 2012 2013
Libreto info up 2012 2013
Proceso Jinamar
 
Chevron corp
Chevron corpChevron corp
Chevron corp
Rostyslav Lytvyn
 
Nomadasmodernos
NomadasmodernosNomadasmodernos
Nomadasmodernos
mariacamilasepulvedacsj
 
Actividad de emprendimiento
Actividad de emprendimientoActividad de emprendimiento
Actividad de emprendimiento
mariacamilasepulvedacsj
 
Distributed Pub Subについて
Distributed Pub SubについてDistributed Pub Subについて
Distributed Pub Subについて
Syuhei Hiya
 
Actividad emprendimiento 4
Actividad emprendimiento 4Actividad emprendimiento 4
Actividad emprendimiento 4
mariacamilasepulvedacsj
 
Trabajo partes fundamentales de la computadora
Trabajo partes fundamentales de la computadoraTrabajo partes fundamentales de la computadora
Trabajo partes fundamentales de la computadora
tatiana monsalve
 
Shawn Robinson_Lab5
Shawn Robinson_Lab5Shawn Robinson_Lab5
Shawn Robinson_Lab5
Shawn Robinson
 

Viewers also liked (18)

Juan jesús vite serrano
Juan jesús vite serranoJuan jesús vite serrano
Juan jesús vite serrano
 
Microsoft word mayo
Microsoft word   mayo Microsoft word   mayo
Microsoft word mayo
 
Emprendimiento
EmprendimientoEmprendimiento
Emprendimiento
 
Redes de valor y calidad
Redes de valor y calidadRedes de valor y calidad
Redes de valor y calidad
 
Maria camila sepulveda 7a
Maria camila sepulveda 7aMaria camila sepulveda 7a
Maria camila sepulveda 7a
 
Trabajo 7 a
Trabajo 7 aTrabajo 7 a
Trabajo 7 a
 
Programa pdf
Programa pdfPrograma pdf
Programa pdf
 
Geometria consulta terminos no defeinidos
Geometria consulta terminos no defeinidosGeometria consulta terminos no defeinidos
Geometria consulta terminos no defeinidos
 
Monica rojas
Monica rojasMonica rojas
Monica rojas
 
Saberes previos
Saberes previosSaberes previos
Saberes previos
 
Libreto info up 2012 2013
Libreto info up 2012 2013Libreto info up 2012 2013
Libreto info up 2012 2013
 
Chevron corp
Chevron corpChevron corp
Chevron corp
 
Nomadasmodernos
NomadasmodernosNomadasmodernos
Nomadasmodernos
 
Actividad de emprendimiento
Actividad de emprendimientoActividad de emprendimiento
Actividad de emprendimiento
 
Distributed Pub Subについて
Distributed Pub SubについてDistributed Pub Subについて
Distributed Pub Subについて
 
Actividad emprendimiento 4
Actividad emprendimiento 4Actividad emprendimiento 4
Actividad emprendimiento 4
 
Trabajo partes fundamentales de la computadora
Trabajo partes fundamentales de la computadoraTrabajo partes fundamentales de la computadora
Trabajo partes fundamentales de la computadora
 
Shawn Robinson_Lab5
Shawn Robinson_Lab5Shawn Robinson_Lab5
Shawn Robinson_Lab5
 

Similar to R data-structures-3

R training3
R training3R training3
R training3
Hellen Gakuruh
 
II B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxII B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptx
sabithabanu83
 
DataStructures.pptx
DataStructures.pptxDataStructures.pptx
DataStructures.pptx
Thanuj Pothula
 
Array
ArrayArray
Array
Fahuda E
 
Unit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptxUnit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptx
SreeLaya9
 
Introduction to R _IMPORTANT FOR DATA ANALYTICS
Introduction to R _IMPORTANT FOR DATA ANALYTICSIntroduction to R _IMPORTANT FOR DATA ANALYTICS
Introduction to R _IMPORTANT FOR DATA ANALYTICS
HaritikaChhatwal1
 
Array
ArrayArray
Programming with R in Big Data Analytics
Programming with R in Big Data AnalyticsProgramming with R in Big Data Analytics
Programming with R in Big Data Analytics
Archana Gopinath
 
Introduction to R for Data Science :: Session 2
Introduction to R for Data Science :: Session 2Introduction to R for Data Science :: Session 2
Introduction to R for Data Science :: Session 2
Goran S. Milovanovic
 
2. Array in Data Structure
2. Array in Data Structure2. Array in Data Structure
2. Array in Data Structure
Mandeep Singh
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
Satish Gummadi
 
Chapter 2 Basics of MATLAB
Chapter 2 Basics of MATLABChapter 2 Basics of MATLAB
Chapter 2 Basics of MATLAB
Pranoti Doke
 
Matrix operations in MATLAB
Matrix operations in MATLABMatrix operations in MATLAB
Matrix operations in MATLAB
Saloni Singhal
 
MATLAB_CIS601-03.ppt
MATLAB_CIS601-03.pptMATLAB_CIS601-03.ppt
MATLAB_CIS601-03.ppt
aboma2hawi
 
MatlabIntro (1).ppt
MatlabIntro (1).pptMatlabIntro (1).ppt
MatlabIntro (1).ppt
AkashSingh728626
 
Array 2 hina
Array 2 hina Array 2 hina
Array 2 hina
heena94
 
Arrays_and_Strings_in_C_Programming.pptx
Arrays_and_Strings_in_C_Programming.pptxArrays_and_Strings_in_C_Programming.pptx
Arrays_and_Strings_in_C_Programming.pptx
samreenghauri786
 
Basics R.ppt
Basics R.pptBasics R.ppt
Basics R.ppt
AtulTandan
 
INTRODUCTION TO MATLAB for PG students.ppt
INTRODUCTION TO MATLAB for PG students.pptINTRODUCTION TO MATLAB for PG students.ppt
INTRODUCTION TO MATLAB for PG students.ppt
Karthik537368
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
NavyaParashir
 

Similar to R data-structures-3 (20)

R training3
R training3R training3
R training3
 
II B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxII B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptx
 
DataStructures.pptx
DataStructures.pptxDataStructures.pptx
DataStructures.pptx
 
Array
ArrayArray
Array
 
Unit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptxUnit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptx
 
Introduction to R _IMPORTANT FOR DATA ANALYTICS
Introduction to R _IMPORTANT FOR DATA ANALYTICSIntroduction to R _IMPORTANT FOR DATA ANALYTICS
Introduction to R _IMPORTANT FOR DATA ANALYTICS
 
Array
ArrayArray
Array
 
Programming with R in Big Data Analytics
Programming with R in Big Data AnalyticsProgramming with R in Big Data Analytics
Programming with R in Big Data Analytics
 
Introduction to R for Data Science :: Session 2
Introduction to R for Data Science :: Session 2Introduction to R for Data Science :: Session 2
Introduction to R for Data Science :: Session 2
 
2. Array in Data Structure
2. Array in Data Structure2. Array in Data Structure
2. Array in Data Structure
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Chapter 2 Basics of MATLAB
Chapter 2 Basics of MATLABChapter 2 Basics of MATLAB
Chapter 2 Basics of MATLAB
 
Matrix operations in MATLAB
Matrix operations in MATLABMatrix operations in MATLAB
Matrix operations in MATLAB
 
MATLAB_CIS601-03.ppt
MATLAB_CIS601-03.pptMATLAB_CIS601-03.ppt
MATLAB_CIS601-03.ppt
 
MatlabIntro (1).ppt
MatlabIntro (1).pptMatlabIntro (1).ppt
MatlabIntro (1).ppt
 
Array 2 hina
Array 2 hina Array 2 hina
Array 2 hina
 
Arrays_and_Strings_in_C_Programming.pptx
Arrays_and_Strings_in_C_Programming.pptxArrays_and_Strings_in_C_Programming.pptx
Arrays_and_Strings_in_C_Programming.pptx
 
Basics R.ppt
Basics R.pptBasics R.ppt
Basics R.ppt
 
INTRODUCTION TO MATLAB for PG students.ppt
INTRODUCTION TO MATLAB for PG students.pptINTRODUCTION TO MATLAB for PG students.ppt
INTRODUCTION TO MATLAB for PG students.ppt
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
 

Recently uploaded

Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
roli9797
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
74nqk8xf
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
dwreak4tg
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
vikram sood
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Aggregage
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
v7oacc3l
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
mbawufebxi
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
74nqk8xf
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
bopyb
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
nuttdpt
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
nyfuhyz
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
aqzctr7x
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
Sm321
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdfEnhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
GetInData
 
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
74nqk8xf
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Kiwi Creative
 
University of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma TranscriptUniversity of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma Transcript
soxrziqu
 

Recently uploaded (20)

Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
 
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
一比一原版(Chester毕业证书)切斯特大学毕业证如何办理
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdfEnhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
 
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
 
University of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma TranscriptUniversity of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma Transcript
 

R data-structures-3

  • 1. R Data Structures (Pt. III) WMG Training Nov 2016 National Environmental Standards and Regulations Enforcement Agency (NESREA) Facilitator: Victor Ordu
  • 2. Types of Data Structures 1. Vectors 2. Data frames 3. Matrices 4. Lists 5. Arrays
  • 3.
  • 4. Matrices • Like data frame are 2-dimensional – rows & columns • Like vectors, only of particular type – integer, character, numeric, logical, etc. • Can be built using matrix() • Others include rbind(), cbind() • Matrix arithmetic possible in R but not our focus
  • 5. • Matrix creation is also useful in other operations such as drawing multiple plots • Exploring a matrix is somewhat similar to that of a data frame – dim() – typeof() – class()
  • 6. • Download and run the script create-matrix.R to make a matrix, mat Note: Save the script from your browser as a .R file
  • 7. Indexing • This is a crucial aspect of R programming • Enable you to get or set elements of a data structure • Bracket operator “[ ]” is used for indexing – For vectors: [ ] – For matrices & data frames: [ , ] – For lists: [ ] and [[ ]]
  • 8. • The format for indexing is [row, column] – [1, 2] means “first row, second column” • This notation is like mapping the location of an element in a 2-dimensional data structure.
  • 9. • If you want to get a matrix value on the 4th row and the 3rd column, you run: matrix[4, 3]
  • 10. • If you want to change a matrix value on the 4th row and the 3rd column, you run: matrix[4, 3] <- <new value>
  • 11. • Ranges also work well with indexing – First 3 rows of column 2 is written as [1:3, 2]
  • 12. – Row 4 of columns 2 to 4 is coded as [4, 2:4]
  • 13. • Note the indices (or is it indexes?) of the matrix along the margins of the output (also, learn that there is no trivial or frivolous output in R. Studying it can teach you a lot!)
  • 14. • Nit-picking is also possible – To select rows 2 & 4 of columns 3 & 5 write [c(2, 4), c(3, 5)] # select with c()
  • 15. • An empty value means ‘ALL’ – E.g. [, 5] (means ‘all rows in column 5’)
  • 16. • Negative indexing is there too! – Row 2 except column 5 is written as [2, -5]
  • 17. Indexing is for vectors too! • Bracket notation applies to vectors • Because they have 1 dimension, there will be no comma inside the brackets i.e. [ ] and not [ , ] • Try it out!
  • 18. Homogenous Heterogeneous 1-dimension Atomic vectors Lists 2-dimensions Matrices Data frames N-dimensions Arrays

Editor's Notes

  1. <new value> must match the “type” of the existing matrix values.