SlideShare a Scribd company logo
1 of 27
R Data Structures
WMG Training
Sept 2016
National Environmental Standards and Regulations Enforcement Agency
(NESREA)
Facilitator: Victor Ordu
Source: H Wickham (2014). Advanced R. Chapman & Hall, Boca Raton. http://adv-r.had.co.nz/
Recap
Recap
• Caveat
– Not everything I will tell you will be 100% correct
– Why?
• Stupid mistakes
• Updates
• New knowledge
• Multiple approaches, some better than others
• Continuous learning
– Moral: commit to personal growth
Notation
• Regular text with look like this…
• Highlighted items will look like this…
• this <- R_code(“will look like”)
Types of Data Structures
1. Vectors
2. Data frames
3. Matrices
4. Lists
5. Arrays
Types of Data Structures
1. Vectors
2. Data frames
3. Matrices
4. Lists
5. Arrays
Kinds of Vectors
• Six (6) kinds:
1. Character
2. Integer
3. Double (or numeric)
4. Logical
Vectors
• Common characteristics
– All elements are of a particular data type (in lay
language, “type” would be numbers, words, etc.)
– One-dimensional
– The lowest vector is of length 1
– The largest … well, depends on the .Machine
Making vectors
• By assignment
– The concatenate function
• Latin: con – caten – atus (chain)
• Some call it “combine” function
• Indispensible in creating vectors
• You can ‘grow’ a vector
– You may ask how, much, much, much, much later
• Character vectors
– Strings are always placed in quotation marks when
coding i.e. “boy”, “NESREA”, “R is easy to
learn”, “A string can be a whole
sentence!”, “9”.
– Some character vectors are inbuilt into R e.g.
letters, LETTERS, month.abb, month.name
– Remember use quotation marks: “ ” or ‘ ’.
– We can create empty vectors with specific lengths e.g.
character(length = 10) or character(10)
– Limit approx. 231 (about 2 billion)
characters!
– Exercise
• Start a clean slate with rm(list = ls())
• Make a character vector Name containing full names
(both Surname and Given Name) of 10 adults
• Make a second vector Facility of names of 10
facilities (imaginary, please!)
• Use typeof() to check what type of vector Name is
• Confirm the type of Facility using
is.character()
• Note: We can use as.character() to convert
another vector to a character vector.
• Integer vectors
– 1L, 2L, 3L
• Why the ‘L’?
– Not numerical per se
– Wide range – max up to 2,147,483,647
– Exercise
• Make an integer vector Age of 10 adult subjects
• Make an integer vector StaffStrength for 10 facilities
• Numeric (double) vectors
– These are real numbers
– Story of the term double
– Some numeric vectors are inbuilt – mathematical
constants e.g. pi, exp(1),
• Logical vectors
– TRUE/FALSE (not true/false); T/F
– Zero is FALSE; any non-zero is TRUE
– Exercise
• Make a logical vector PermitSighted for 10 facilities.
• Make another one usingPPE for 10 individuals.
• Use str(), typeof(), is.logical(), to explore them.
Stats brief
• Types of variables
– Quantitative
– Qualitative
• Levels of measurement
– Nominal
– Ordinal
– Interval
– Ratio
Factors
• Integer values that are mapped to “strings”
• Used to represent categorical data
• Each category is called a level
• One of the most powerful uses of R
– Exercise
• Make a vector industryType using 3 categories – small,
medium, large – for 10 facilities only.
• Make a factor industryCategory by calling the function
factor() on industryType.
• Now use typeof(), is.factor, is.character,
is.integer() to review these 2 objects.
Things to note…
• Legal names
• Coercion
• Limits
• Common mistakes
– Confusing factors with characters
Homogenous Heterogeneous
1-dimension Atomic vectors Lists
2-dimensions Matrices Data frames
N-dimensions Arrays
> R toolbox
› help() or ?
› getwd(); setwd()
› ls()
› rm()
› save(); load()
> R toolbox
• An example – ls()
– It’s relatively easy to see all the objects at a glance
– Note that this function is called without any
arguments
> R toolbox
• But how do you deal with this?
Long list beyond screen
> R toolbox
– Extend use of functions by defining other
parameters (optional)
– Use ? to learn about a function’s uses &
arguments
– When more familiar, use others like args()
> R toolbox
Types of Data Structures
1. Vectors
2. Data frames
3. Matrices
4. Lists
5. 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 polytechniclavparmar007
 
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 JYOTHISowmya Jyothi
 
Introduction to Data Structure part 1
Introduction to Data Structure part 1Introduction to Data Structure part 1
Introduction to Data Structure part 1ProfSonaliGholveDoif
 
Arrays declartion and initialization
Arrays declartion and initializationArrays declartion and initialization
Arrays declartion and initializationsangrampatil81
 
Files and data storage
Files and data storageFiles and data storage
Files and data storageZaid Shabbir
 
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 JYOTHISowmya Jyothi
 
Introduction of data structures and algorithms
Introduction of data structures and algorithmsIntroduction of data structures and algorithms
Introduction of data structures and algorithmsVinayKumarV16
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURERohit Rai
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structureVivek Kumar Sinha
 
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 questionsProf. 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
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceTransweb Global Inc
 
How to handling strings in r
How to handling strings in rHow to handling strings in r
How to handling strings in rPramod Rathore
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsAakash deep Singhal
 

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
 
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 to Data Structure part 1
Introduction to Data Structure part 1Introduction to Data Structure part 1
Introduction to Data Structure part 1
 
Arrays in C
Arrays in CArrays in C
Arrays in C
 
Arrays declartion and initialization
Arrays declartion and initializationArrays declartion and initialization
Arrays declartion and initialization
 
Files and data storage
Files and data storageFiles and data storage
Files and data storage
 
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
 
Introduction of data structures and algorithms
Introduction of data structures and algorithmsIntroduction of data structures and algorithms
Introduction of data structures and algorithms
 
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]
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
 
Rdbms
RdbmsRdbms
Rdbms
 
How to handling strings in r
How to handling strings in rHow to handling strings in r
How to handling strings in r
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
 
Data Structures
Data StructuresData Structures
Data Structures
 

Similar to R Data Structures (Part 1)

Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersVitomir Kovanovic
 
Big data analytics with R tool.pptx
Big data analytics with R tool.pptxBig data analytics with R tool.pptx
Big data analytics with R tool.pptxsalutiontechnology
 
Intro to data science module 1 r
Intro to data science module 1 rIntro to data science module 1 r
Intro to data science module 1 ramuletc
 
Advanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAdvanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAnshika865276
 
Basic data analysis using R.
Basic data analysis using R.Basic data analysis using R.
Basic data analysis using R.C. Tobin Magle
 
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.pptxSreeLaya9
 
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdfProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdflailoesakhan
 
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdfProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdflailoesakhan
 
Introduction to basic statistics
Introduction to basic statisticsIntroduction to basic statistics
Introduction to basic statisticsIBM
 
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 ANALYTICSHaritikaChhatwal1
 
Introduction to R.pptx
Introduction to R.pptxIntroduction to R.pptx
Introduction to R.pptxAvinabaHandson
 
ch6-Short.ppt eee cse www rrr www qqq rrr ttt
ch6-Short.ppt eee cse www rrr www qqq rrr tttch6-Short.ppt eee cse www rrr www qqq rrr ttt
ch6-Short.ppt eee cse www rrr www qqq rrr tttwinimag331
 

Similar to R Data Structures (Part 1) (20)

Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics Researchers
 
R tutorial
R tutorialR tutorial
R tutorial
 
R training2
R training2R training2
R training2
 
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي   R program د.هديل القفيديمحاضرة برنامج التحليل الكمي   R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
 
Big data analytics with R tool.pptx
Big data analytics with R tool.pptxBig data analytics with R tool.pptx
Big data analytics with R tool.pptx
 
Intro to data science module 1 r
Intro to data science module 1 rIntro to data science module 1 r
Intro to data science module 1 r
 
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي   R program د.هديل القفيديمحاضرة برنامج التحليل الكمي   R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
 
Advanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAdvanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.ppt
 
Basic data analysis using R.
Basic data analysis using R.Basic data analysis using R.
Basic data analysis using R.
 
R programming by ganesh kavhar
R programming by ganesh kavharR programming by ganesh kavhar
R programming by ganesh kavhar
 
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
 
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdfProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
ProgFund_Lecture_3_Data_Structures_and_Iteration-1.pdf
 
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdfProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
ProgPrinc_Lecture_3_Data_Structures_and_Iteration-2.pdf
 
Introduction to basic statistics
Introduction to basic statisticsIntroduction to basic statistics
Introduction to basic statistics
 
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
 
Introduction to R.pptx
Introduction to R.pptxIntroduction to R.pptx
Introduction to R.pptx
 
R data types
R data typesR data types
R data types
 
Java session3
Java session3Java session3
Java session3
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
ch6-Short.ppt eee cse www rrr www qqq rrr ttt
ch6-Short.ppt eee cse www rrr www qqq rrr tttch6-Short.ppt eee cse www rrr www qqq rrr ttt
ch6-Short.ppt eee cse www rrr www qqq rrr ttt
 

Recently uploaded

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 

Recently uploaded (20)

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 

R Data Structures (Part 1)

  • 1. R Data Structures WMG Training Sept 2016 National Environmental Standards and Regulations Enforcement Agency (NESREA) Facilitator: Victor Ordu
  • 2. Source: H Wickham (2014). Advanced R. Chapman & Hall, Boca Raton. http://adv-r.had.co.nz/
  • 5. • Caveat – Not everything I will tell you will be 100% correct – Why? • Stupid mistakes • Updates • New knowledge • Multiple approaches, some better than others • Continuous learning – Moral: commit to personal growth
  • 6. Notation • Regular text with look like this… • Highlighted items will look like this… • this <- R_code(“will look like”)
  • 7. Types of Data Structures 1. Vectors 2. Data frames 3. Matrices 4. Lists 5. Arrays
  • 8. Types of Data Structures 1. Vectors 2. Data frames 3. Matrices 4. Lists 5. Arrays
  • 9.
  • 10. Kinds of Vectors • Six (6) kinds: 1. Character 2. Integer 3. Double (or numeric) 4. Logical
  • 11. Vectors • Common characteristics – All elements are of a particular data type (in lay language, “type” would be numbers, words, etc.) – One-dimensional – The lowest vector is of length 1 – The largest … well, depends on the .Machine
  • 12. Making vectors • By assignment – The concatenate function • Latin: con – caten – atus (chain) • Some call it “combine” function • Indispensible in creating vectors • You can ‘grow’ a vector – You may ask how, much, much, much, much later
  • 13. • Character vectors – Strings are always placed in quotation marks when coding i.e. “boy”, “NESREA”, “R is easy to learn”, “A string can be a whole sentence!”, “9”. – Some character vectors are inbuilt into R e.g. letters, LETTERS, month.abb, month.name – Remember use quotation marks: “ ” or ‘ ’. – We can create empty vectors with specific lengths e.g. character(length = 10) or character(10) – Limit approx. 231 (about 2 billion) characters!
  • 14. – Exercise • Start a clean slate with rm(list = ls()) • Make a character vector Name containing full names (both Surname and Given Name) of 10 adults • Make a second vector Facility of names of 10 facilities (imaginary, please!) • Use typeof() to check what type of vector Name is • Confirm the type of Facility using is.character() • Note: We can use as.character() to convert another vector to a character vector.
  • 15. • Integer vectors – 1L, 2L, 3L • Why the ‘L’? – Not numerical per se – Wide range – max up to 2,147,483,647 – Exercise • Make an integer vector Age of 10 adult subjects • Make an integer vector StaffStrength for 10 facilities
  • 16. • Numeric (double) vectors – These are real numbers – Story of the term double – Some numeric vectors are inbuilt – mathematical constants e.g. pi, exp(1),
  • 17. • Logical vectors – TRUE/FALSE (not true/false); T/F – Zero is FALSE; any non-zero is TRUE – Exercise • Make a logical vector PermitSighted for 10 facilities. • Make another one usingPPE for 10 individuals. • Use str(), typeof(), is.logical(), to explore them.
  • 18. Stats brief • Types of variables – Quantitative – Qualitative • Levels of measurement – Nominal – Ordinal – Interval – Ratio
  • 19. Factors • Integer values that are mapped to “strings” • Used to represent categorical data • Each category is called a level • One of the most powerful uses of R – Exercise • Make a vector industryType using 3 categories – small, medium, large – for 10 facilities only. • Make a factor industryCategory by calling the function factor() on industryType. • Now use typeof(), is.factor, is.character, is.integer() to review these 2 objects.
  • 20. Things to note… • Legal names • Coercion • Limits • Common mistakes – Confusing factors with characters
  • 21. Homogenous Heterogeneous 1-dimension Atomic vectors Lists 2-dimensions Matrices Data frames N-dimensions Arrays
  • 22. > R toolbox › help() or ? › getwd(); setwd() › ls() › rm() › save(); load()
  • 23. > R toolbox • An example – ls() – It’s relatively easy to see all the objects at a glance – Note that this function is called without any arguments
  • 24. > R toolbox • But how do you deal with this? Long list beyond screen
  • 25. > R toolbox – Extend use of functions by defining other parameters (optional) – Use ? to learn about a function’s uses & arguments – When more familiar, use others like args()
  • 27. Types of Data Structures 1. Vectors 2. Data frames 3. Matrices 4. Lists 5. Arrays

Editor's Notes

  1. In the Bible (presumably KJV): 3,566,480 letters 31,102 verses 1,189 chapters