SlideShare a Scribd company logo
1 of 10
R Data Structures
(Pt. IV)
WMG Training
Dec 2016
National Environmental Standards and Regulations Enforcement Agency
(NESREA)
Facilitator: Victor Ordu
Lists
• R lists are unique data structures – very
versatile
• Heterogenous – can hold any kind of R object
in memory, whether singly or in combination
• A list can also contain lists
Making a list
• The function list() is used to form a list;
also as.list().
• Download the sample script create-list.R to
see how lists can be formed
• Run each line of code and carefully study the
output.
• Observe that the code constructs list(s) of all
the R objects studied thus far (and more!)
Quiz
1. How many list elements are there in
mumbo_jumbo?
2. List the different types of R objects you can
find among the elements.
Indexing lists
• The bracket operator [] is also used to extract
elements of a list
– Single []
• Will give you a list i.e. a sub-list.
– Double [[]]
• Will give you the actual element or content.
– Looking at str(), you may notice that $ also
identifies each element of the list.
• To access them the elements must be named – easily done
with the function names()
Exercises
– Run mumbo_jumbo[1], and then
mumbo_jumbo[[1]]
– Now call typeof() on each of them e.g.
typeof(mumbo_jumbo[1])
– Discuss the output.
– A well-known expert recently shared a photo on
Twitter to help understanding of R list indexing.
Click here to view it. Discuss.
Data frames are lists!
• Recall that $ is used to mark named columns
of a data frame
• Also recall that each column in a data frame
can stand alone as a vector
• A data frame is essentially a list with these
characteristics
– Made up of vectors
– All the vectors are of equal length (i.e. no. of rows)
• Run typeof() on any data frame to check this!
Challenge
• Name the elements of mumbo_jumbo with the names() function as
follows:
1. Calcium
2. EAR_done
3. Bin.code
4. Bin.code_expt
5. filesOnFlash
6. Circle
7. table_def
8. MS_simul
9. NESREA_hex
10. NESREA_bits
• Jointly use the name and $ to extract any element from the list.
• What is the type of the extracted element? What does that tell you
about the nature of indexing done with the $ operator?
Conclusion
• The aim of this training session is to equip you with skills and tools
to begin basic analysis of social media data.
• Social media sites offer an API for easy access to organised data.
• Facebook & Twitter data are downloaded as objects that can be
handled in R i.e. lists, data frames, etc.
• To make use of these data, we will use the R packages called
twitteR and Rfacebook, developed by Jeff Gentry & Pablo
Barbera, respectively.
• We will start with Twitter first. To prepare for the next session:
– Run install.packages(“twitteR”), to get the package (requires
internet connection)
– If curious, you can look through the documentation by running
help(package = “twitteR”)
• Thanks for your kind attention.

More Related Content

Viewers also liked

Heater circuit error 26OCT2015
Heater circuit error 26OCT2015Heater circuit error 26OCT2015
Heater circuit error 26OCT2015Tsuyoshi Horigome
 
Bacardi:Presented by Straight &Chaser
Bacardi:Presented by Straight &ChaserBacardi:Presented by Straight &Chaser
Bacardi:Presented by Straight &ChaserPenny Mathebula
 
Word formation
Word formationWord formation
Word formationivunak
 
Metodo cientifico 1
Metodo cientifico 1 Metodo cientifico 1
Metodo cientifico 1 zhober
 
Cuadro comparativo
Cuadro comparativoCuadro comparativo
Cuadro comparativozhober
 
Proofed_Adnan Resume 11-9-16
Proofed_Adnan Resume 11-9-16Proofed_Adnan Resume 11-9-16
Proofed_Adnan Resume 11-9-16Adnan Alattiyat
 
nFusion's B2C Case Studies
nFusion's B2C Case StudiesnFusion's B2C Case Studies
nFusion's B2C Case StudiesnFusion
 
Infographic_Data-Health-Check
Infographic_Data-Health-CheckInfographic_Data-Health-Check
Infographic_Data-Health-CheckOceanos
 
Metodo ingenieril.
Metodo ingenieril.Metodo ingenieril.
Metodo ingenieril.zhober
 
ATENCIÓN AL CLIENTE. El servicio que proporciona una empresa para relacionars...
ATENCIÓN AL CLIENTE. El servicio que proporciona una empresa para relacionars...ATENCIÓN AL CLIENTE. El servicio que proporciona una empresa para relacionars...
ATENCIÓN AL CLIENTE. El servicio que proporciona una empresa para relacionars...jaguelu
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in ScalaDamian Jureczko
 

Viewers also liked (15)

Heater circuit error 26OCT2015
Heater circuit error 26OCT2015Heater circuit error 26OCT2015
Heater circuit error 26OCT2015
 
Self management
Self managementSelf management
Self management
 
Prefixes suffixes
Prefixes suffixesPrefixes suffixes
Prefixes suffixes
 
Bacardi:Presented by Straight &Chaser
Bacardi:Presented by Straight &ChaserBacardi:Presented by Straight &Chaser
Bacardi:Presented by Straight &Chaser
 
Word formation
Word formationWord formation
Word formation
 
Metodo cientifico 1
Metodo cientifico 1 Metodo cientifico 1
Metodo cientifico 1
 
Diplomado GRD
Diplomado GRDDiplomado GRD
Diplomado GRD
 
Cuadro comparativo
Cuadro comparativoCuadro comparativo
Cuadro comparativo
 
Proofed_Adnan Resume 11-9-16
Proofed_Adnan Resume 11-9-16Proofed_Adnan Resume 11-9-16
Proofed_Adnan Resume 11-9-16
 
nFusion's B2C Case Studies
nFusion's B2C Case StudiesnFusion's B2C Case Studies
nFusion's B2C Case Studies
 
Introduccion1
Introduccion1Introduccion1
Introduccion1
 
Infographic_Data-Health-Check
Infographic_Data-Health-CheckInfographic_Data-Health-Check
Infographic_Data-Health-Check
 
Metodo ingenieril.
Metodo ingenieril.Metodo ingenieril.
Metodo ingenieril.
 
ATENCIÓN AL CLIENTE. El servicio que proporciona una empresa para relacionars...
ATENCIÓN AL CLIENTE. El servicio que proporciona una empresa para relacionars...ATENCIÓN AL CLIENTE. El servicio que proporciona una empresa para relacionars...
ATENCIÓN AL CLIENTE. El servicio que proporciona una empresa para relacionars...
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scala
 

More from Victor Ordu

Introduction to R programming
Introduction to R programmingIntroduction to R programming
Introduction to R programmingVictor Ordu
 
R data-structures-3
R data-structures-3R data-structures-3
R data-structures-3Victor Ordu
 
R data structures-2
R data structures-2R data structures-2
R data structures-2Victor Ordu
 
R Data Structures (Part 1)
R Data Structures (Part 1)R Data Structures (Part 1)
R Data Structures (Part 1)Victor Ordu
 
NV20:2020 The First Implementation Plan (2010 - 2013) - Presented by Hon. M...
NV20:2020   The First Implementation Plan (2010 - 2013) - Presented by Hon. M...NV20:2020   The First Implementation Plan (2010 - 2013) - Presented by Hon. M...
NV20:2020 The First Implementation Plan (2010 - 2013) - Presented by Hon. M...Victor Ordu
 
Primary Postpartum Haemorrhage
Primary Postpartum HaemorrhagePrimary Postpartum Haemorrhage
Primary Postpartum HaemorrhageVictor Ordu
 

More from Victor Ordu (7)

Introduction to R programming
Introduction to R programmingIntroduction to R programming
Introduction to R programming
 
R data-structures-3
R data-structures-3R data-structures-3
R data-structures-3
 
R data structures-2
R data structures-2R data structures-2
R data structures-2
 
R Data Structures (Part 1)
R Data Structures (Part 1)R Data Structures (Part 1)
R Data Structures (Part 1)
 
NV20:2020 The First Implementation Plan (2010 - 2013) - Presented by Hon. M...
NV20:2020   The First Implementation Plan (2010 - 2013) - Presented by Hon. M...NV20:2020   The First Implementation Plan (2010 - 2013) - Presented by Hon. M...
NV20:2020 The First Implementation Plan (2010 - 2013) - Presented by Hon. M...
 
Primary Postpartum Haemorrhage
Primary Postpartum HaemorrhagePrimary Postpartum Haemorrhage
Primary Postpartum Haemorrhage
 
Malaria
MalariaMalaria
Malaria
 

Recently uploaded

Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxMohammedJunaid861692
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxolyaivanovalion
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...shivangimorya083
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 

Recently uploaded (20)

Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptx
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 

R Data Structures (pt. 4)

  • 1. R Data Structures (Pt. IV) WMG Training Dec 2016 National Environmental Standards and Regulations Enforcement Agency (NESREA) Facilitator: Victor Ordu
  • 2. Lists • R lists are unique data structures – very versatile • Heterogenous – can hold any kind of R object in memory, whether singly or in combination • A list can also contain lists
  • 3. Making a list • The function list() is used to form a list; also as.list(). • Download the sample script create-list.R to see how lists can be formed • Run each line of code and carefully study the output. • Observe that the code constructs list(s) of all the R objects studied thus far (and more!)
  • 4. Quiz 1. How many list elements are there in mumbo_jumbo? 2. List the different types of R objects you can find among the elements.
  • 5. Indexing lists • The bracket operator [] is also used to extract elements of a list – Single [] • Will give you a list i.e. a sub-list. – Double [[]] • Will give you the actual element or content. – Looking at str(), you may notice that $ also identifies each element of the list. • To access them the elements must be named – easily done with the function names()
  • 6. Exercises – Run mumbo_jumbo[1], and then mumbo_jumbo[[1]] – Now call typeof() on each of them e.g. typeof(mumbo_jumbo[1]) – Discuss the output. – A well-known expert recently shared a photo on Twitter to help understanding of R list indexing. Click here to view it. Discuss.
  • 7. Data frames are lists! • Recall that $ is used to mark named columns of a data frame • Also recall that each column in a data frame can stand alone as a vector • A data frame is essentially a list with these characteristics – Made up of vectors – All the vectors are of equal length (i.e. no. of rows) • Run typeof() on any data frame to check this!
  • 8. Challenge • Name the elements of mumbo_jumbo with the names() function as follows: 1. Calcium 2. EAR_done 3. Bin.code 4. Bin.code_expt 5. filesOnFlash 6. Circle 7. table_def 8. MS_simul 9. NESREA_hex 10. NESREA_bits • Jointly use the name and $ to extract any element from the list. • What is the type of the extracted element? What does that tell you about the nature of indexing done with the $ operator?
  • 9. Conclusion • The aim of this training session is to equip you with skills and tools to begin basic analysis of social media data. • Social media sites offer an API for easy access to organised data. • Facebook & Twitter data are downloaded as objects that can be handled in R i.e. lists, data frames, etc. • To make use of these data, we will use the R packages called twitteR and Rfacebook, developed by Jeff Gentry & Pablo Barbera, respectively. • We will start with Twitter first. To prepare for the next session: – Run install.packages(“twitteR”), to get the package (requires internet connection) – If curious, you can look through the documentation by running help(package = “twitteR”)
  • 10. • Thanks for your kind attention.