SlideShare a Scribd company logo
R Data Structures
(Pt. II)
WMG Training
Sept - Oct 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
R data structures-2
Data frames
• Commonly used R object
• You will either:
1. Get a data frame
2. Make your own data frame
• Have columns and rows. Usually represent
– Columns variables
– Rows observations
• Each column is actually a vector!
header
row
column
Making a data frame
• A data frame can be built from scratch inside R
using the function data.frame()
• Combines vectors with same length
• Vectors with different lengths are built using
expand.grid() – used for simulations
Importing data (simplified)
• An important skill
• Many datasets are imported as data frames
• A useful file format is .csv
• Key function is read.table() & its variants
• Data can also be imported from other formats
e.g. .xls/.xlsx, .spv, .tab,…
• Easiest way to start –> save Excel files as CSV
• Many useful R packages for diff. data formats
Exploring data frames
• A few functions
– Check dimensions – dim()
– View in spreadsheet format – View()
– Examine structure – str()
– See first/last records – head()/tail()
– Summarise variables – summary()
– See/set names of variable – colnames()
– Check if – is.data.frame()
– Change to – as.data.frame()
– Make changes to data using edit()
Stats brief
• Grouping data
– tabulation
• Measures of central tendency
– Mean
– Median
– Mode
• Measures of dispersion
– Range, IQR
– Variance, Standard deviation
R data structures-2
Example with Twitter data
• Preliminaries
– R package called twitteR; access Twitter data
– Call install.packages(“twitter”)
– Use library(help = “twitteR”) to access
package’s DESCRIPTION file
– Documentation: help(package = “twitteR”)
– Many packages have vignette()s – show you
how to use package
• More preliminaries
– Authenticate i.e. log on through Twitter OAuth
– Our details are found in authentication.R
– Establish connection with setup_twitter_oauth()
• This gives us access to the Twitter data
– Download the data with searchTwitter()
– Convert to data frame with twListToDF()
R data structures-2
R data structures-2
Subsetting
• The $ operator
– Look at str() again
– Note the $ in the output
– You can pick out individual columns with syntax
dataframe$columnname
– Same thing as a vector
– Get to get or set variables
> R toolbox
> search()
> detach()
> library()
> require()
> saveRDS()
> readRDS()
> file.edit()
Homogenous Heterogeneous
1-dimension Atomic vectors Lists
2-dimensions Matrices Data frames
N-dimensions Arrays
Ad

More Related Content

What's hot (20)

Presentation of array
Presentation of arrayPresentation of array
Presentation of array
Shamim Hossain
 
Data structure day1
Data structure day1Data structure day1
Data structure day1
Mohammed Elsdody
 
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
 
R language
R languageR language
R language
Isra El Isa
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its types
Rameesha Sadaqat
 
Pandas
PandasPandas
Pandas
Dr. Chitra Dhawale
 
Introduction to Data Structure part 1
Introduction to Data Structure part 1Introduction to Data Structure part 1
Introduction to Data Structure part 1
ProfSonaliGholveDoif
 
Arrays in C
Arrays in CArrays in C
Arrays in C
sangrampatil81
 
Arrays declartion and initialization
Arrays declartion and initializationArrays declartion and initialization
Arrays declartion and initialization
sangrampatil81
 
Files and data storage
Files and data storageFiles and data storage
Files and data storage
Zaid Shabbir
 
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 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
 
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
 
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
 
Types Of Data Structure
Types Of Data StructureTypes Of Data Structure
Types Of Data Structure
Vaishali Chinchkhede
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
Transweb Global Inc
 
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
 
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
 
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
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its types
Rameesha Sadaqat
 
Introduction to Data Structure part 1
Introduction to Data Structure part 1Introduction to Data Structure part 1
Introduction to Data Structure part 1
ProfSonaliGholveDoif
 
Arrays declartion and initialization
Arrays declartion and initializationArrays declartion and initialization
Arrays declartion and initialization
sangrampatil81
 
Files and data storage
Files and data storageFiles and data storage
Files and data storage
Zaid Shabbir
 
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 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
 
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
 
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 Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
Transweb Global Inc
 
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
 
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
 

Viewers also liked (14)

Seminario FIE 2015
Seminario FIE 2015Seminario FIE 2015
Seminario FIE 2015
ciafieunap
 
Resolucion de acreditacion FIE
Resolucion de acreditacion FIEResolucion de acreditacion FIE
Resolucion de acreditacion FIE
ciafieunap
 
DC10 Jaspar Roos - management of services innovation - creating value through...
DC10 Jaspar Roos - management of services innovation - creating value through...DC10 Jaspar Roos - management of services innovation - creating value through...
DC10 Jaspar Roos - management of services innovation - creating value through...
Jaak Vlasveld
 
English grammar
English grammarEnglish grammar
English grammar
Reziel Manalo
 
Admision Segunda FIE 2016
Admision Segunda FIE 2016Admision Segunda FIE 2016
Admision Segunda FIE 2016
ciafieunap
 
Gestion administrativa su evolucion
Gestion administrativa su evolucionGestion administrativa su evolucion
Gestion administrativa su evolucion
stevewilliam0412
 
Boletin informativo FIE Nro 05
Boletin informativo FIE Nro 05Boletin informativo FIE Nro 05
Boletin informativo FIE Nro 05
ciafieunap
 
Matriculas FIE 2016-I
Matriculas FIE 2016-IMatriculas FIE 2016-I
Matriculas FIE 2016-I
ciafieunap
 
Catalogo de tesis FIE UNA Puno
Catalogo de tesis FIE UNA PunoCatalogo de tesis FIE UNA Puno
Catalogo de tesis FIE UNA Puno
ciafieunap
 
Boletin informativo FIE no. 3
Boletin informativo FIE no. 3Boletin informativo FIE no. 3
Boletin informativo FIE no. 3
ciafieunap
 
Introduction to R programming
Introduction to R programmingIntroduction to R programming
Introduction to R programming
Victor Ordu
 
Digital Transformation at Bacardi
Digital Transformation at BacardiDigital Transformation at Bacardi
Digital Transformation at Bacardi
Mobile Marketing Association
 
حضرت مسیح موعود ؑ کا نبوت پراصرار
حضرت مسیح موعود ؑ کا نبوت پراصرارحضرت مسیح موعود ؑ کا نبوت پراصرار
حضرت مسیح موعود ؑ کا نبوت پراصرار
muzaffertahir9
 
Scala Quick Introduction
Scala Quick IntroductionScala Quick Introduction
Scala Quick Introduction
Damian Jureczko
 
Seminario FIE 2015
Seminario FIE 2015Seminario FIE 2015
Seminario FIE 2015
ciafieunap
 
Resolucion de acreditacion FIE
Resolucion de acreditacion FIEResolucion de acreditacion FIE
Resolucion de acreditacion FIE
ciafieunap
 
DC10 Jaspar Roos - management of services innovation - creating value through...
DC10 Jaspar Roos - management of services innovation - creating value through...DC10 Jaspar Roos - management of services innovation - creating value through...
DC10 Jaspar Roos - management of services innovation - creating value through...
Jaak Vlasveld
 
Admision Segunda FIE 2016
Admision Segunda FIE 2016Admision Segunda FIE 2016
Admision Segunda FIE 2016
ciafieunap
 
Gestion administrativa su evolucion
Gestion administrativa su evolucionGestion administrativa su evolucion
Gestion administrativa su evolucion
stevewilliam0412
 
Boletin informativo FIE Nro 05
Boletin informativo FIE Nro 05Boletin informativo FIE Nro 05
Boletin informativo FIE Nro 05
ciafieunap
 
Matriculas FIE 2016-I
Matriculas FIE 2016-IMatriculas FIE 2016-I
Matriculas FIE 2016-I
ciafieunap
 
Catalogo de tesis FIE UNA Puno
Catalogo de tesis FIE UNA PunoCatalogo de tesis FIE UNA Puno
Catalogo de tesis FIE UNA Puno
ciafieunap
 
Boletin informativo FIE no. 3
Boletin informativo FIE no. 3Boletin informativo FIE no. 3
Boletin informativo FIE no. 3
ciafieunap
 
Introduction to R programming
Introduction to R programmingIntroduction to R programming
Introduction to R programming
Victor Ordu
 
حضرت مسیح موعود ؑ کا نبوت پراصرار
حضرت مسیح موعود ؑ کا نبوت پراصرارحضرت مسیح موعود ؑ کا نبوت پراصرار
حضرت مسیح موعود ؑ کا نبوت پراصرار
muzaffertahir9
 
Scala Quick Introduction
Scala Quick IntroductionScala Quick Introduction
Scala Quick Introduction
Damian Jureczko
 
Ad

Recently uploaded (20)

Kilowatt's Impact Report _ 2024 x
Kilowatt's Impact Report _ 2024                xKilowatt's Impact Report _ 2024                x
Kilowatt's Impact Report _ 2024 x
Kilowatt
 
Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]
globibo
 
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm     mmmmmfftro.pptxlecture_13 tree in mmmmmmmm     mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
sarajafffri058
 
Introduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdfIntroduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdf
AbdurahmanAbd
 
Digital Disruption Use Case_Music Industry_for students.pdf
Digital Disruption Use Case_Music Industry_for students.pdfDigital Disruption Use Case_Music Industry_for students.pdf
Digital Disruption Use Case_Music Industry_for students.pdf
ProsenjitMitra9
 
presentacion.slideshare.informáticaJuridica..pptx
presentacion.slideshare.informáticaJuridica..pptxpresentacion.slideshare.informáticaJuridica..pptx
presentacion.slideshare.informáticaJuridica..pptx
GersonVillatoro4
 
Peeling the onion: How to move through multiple discovery and analysis cycles
Peeling the onion: How to move through multiple discovery and analysis cyclesPeeling the onion: How to move through multiple discovery and analysis cycles
Peeling the onion: How to move through multiple discovery and analysis cycles
Process mining Evangelist
 
CS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docxCS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docx
nidarizvitit
 
End to End Process Analysis - Cox Communications
End to End Process Analysis - Cox CommunicationsEnd to End Process Analysis - Cox Communications
End to End Process Analysis - Cox Communications
Process mining Evangelist
 
Professional Certificate in Applied AI and Machine Learning
Professional Certificate in Applied AI and Machine LearningProfessional Certificate in Applied AI and Machine Learning
Professional Certificate in Applied AI and Machine Learning
Nafisur Ahmed
 
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdfPublication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
StatsCommunications
 
Lesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdfLesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdf
hemelali11
 
Red Hat Openshift Training - openshift (1).pptx
Red Hat Openshift Training - openshift (1).pptxRed Hat Openshift Training - openshift (1).pptx
Red Hat Openshift Training - openshift (1).pptx
ssuserf60686
 
Get Started with FukreyGame Today!......
Get Started with FukreyGame Today!......Get Started with FukreyGame Today!......
Get Started with FukreyGame Today!......
liononline785
 
Storage Devices and the Mechanism of Data Storage in Audio and Visual Form
Storage Devices and the Mechanism of Data Storage in Audio and Visual FormStorage Devices and the Mechanism of Data Storage in Audio and Visual Form
Storage Devices and the Mechanism of Data Storage in Audio and Visual Form
Professional Content Writing's
 
2024 Digital Equity Accelerator Report.pdf
2024 Digital Equity Accelerator Report.pdf2024 Digital Equity Accelerator Report.pdf
2024 Digital Equity Accelerator Report.pdf
dominikamizerska1
 
390713553-Introduction-to-Apportionment-and-Voting.pptx
390713553-Introduction-to-Apportionment-and-Voting.pptx390713553-Introduction-to-Apportionment-and-Voting.pptx
390713553-Introduction-to-Apportionment-and-Voting.pptx
KhimJDAbordo
 
DATA ANALYST and Techniques in Kochi Explore cutting-edge analytical skills ...
DATA ANALYST  and Techniques in Kochi Explore cutting-edge analytical skills ...DATA ANALYST  and Techniques in Kochi Explore cutting-edge analytical skills ...
DATA ANALYST and Techniques in Kochi Explore cutting-edge analytical skills ...
aacj102006
 
Introduction to Artificial Intelligence_ Lec 2
Introduction to Artificial Intelligence_ Lec 2Introduction to Artificial Intelligence_ Lec 2
Introduction to Artificial Intelligence_ Lec 2
Dalal2Ali
 
Time series analysis & forecasting day 2.pptx
Time series analysis & forecasting day 2.pptxTime series analysis & forecasting day 2.pptx
Time series analysis & forecasting day 2.pptx
AsmaaMahmoud89
 
Kilowatt's Impact Report _ 2024 x
Kilowatt's Impact Report _ 2024                xKilowatt's Impact Report _ 2024                x
Kilowatt's Impact Report _ 2024 x
Kilowatt
 
Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]
globibo
 
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm     mmmmmfftro.pptxlecture_13 tree in mmmmmmmm     mmmmmfftro.pptx
lecture_13 tree in mmmmmmmm mmmmmfftro.pptx
sarajafffri058
 
Introduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdfIntroduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdf
AbdurahmanAbd
 
Digital Disruption Use Case_Music Industry_for students.pdf
Digital Disruption Use Case_Music Industry_for students.pdfDigital Disruption Use Case_Music Industry_for students.pdf
Digital Disruption Use Case_Music Industry_for students.pdf
ProsenjitMitra9
 
presentacion.slideshare.informáticaJuridica..pptx
presentacion.slideshare.informáticaJuridica..pptxpresentacion.slideshare.informáticaJuridica..pptx
presentacion.slideshare.informáticaJuridica..pptx
GersonVillatoro4
 
Peeling the onion: How to move through multiple discovery and analysis cycles
Peeling the onion: How to move through multiple discovery and analysis cyclesPeeling the onion: How to move through multiple discovery and analysis cycles
Peeling the onion: How to move through multiple discovery and analysis cycles
Process mining Evangelist
 
CS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docxCS-404 COA COURSE FILE JAN JUN 2025.docx
CS-404 COA COURSE FILE JAN JUN 2025.docx
nidarizvitit
 
End to End Process Analysis - Cox Communications
End to End Process Analysis - Cox CommunicationsEnd to End Process Analysis - Cox Communications
End to End Process Analysis - Cox Communications
Process mining Evangelist
 
Professional Certificate in Applied AI and Machine Learning
Professional Certificate in Applied AI and Machine LearningProfessional Certificate in Applied AI and Machine Learning
Professional Certificate in Applied AI and Machine Learning
Nafisur Ahmed
 
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdfPublication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
Publication-launch-How-is-Life-for-Children-in-the-Digital-Age-15-May-2025.pdf
StatsCommunications
 
Lesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdfLesson 6-Interviewing in SHRM_updated.pdf
Lesson 6-Interviewing in SHRM_updated.pdf
hemelali11
 
Red Hat Openshift Training - openshift (1).pptx
Red Hat Openshift Training - openshift (1).pptxRed Hat Openshift Training - openshift (1).pptx
Red Hat Openshift Training - openshift (1).pptx
ssuserf60686
 
Get Started with FukreyGame Today!......
Get Started with FukreyGame Today!......Get Started with FukreyGame Today!......
Get Started with FukreyGame Today!......
liononline785
 
Storage Devices and the Mechanism of Data Storage in Audio and Visual Form
Storage Devices and the Mechanism of Data Storage in Audio and Visual FormStorage Devices and the Mechanism of Data Storage in Audio and Visual Form
Storage Devices and the Mechanism of Data Storage in Audio and Visual Form
Professional Content Writing's
 
2024 Digital Equity Accelerator Report.pdf
2024 Digital Equity Accelerator Report.pdf2024 Digital Equity Accelerator Report.pdf
2024 Digital Equity Accelerator Report.pdf
dominikamizerska1
 
390713553-Introduction-to-Apportionment-and-Voting.pptx
390713553-Introduction-to-Apportionment-and-Voting.pptx390713553-Introduction-to-Apportionment-and-Voting.pptx
390713553-Introduction-to-Apportionment-and-Voting.pptx
KhimJDAbordo
 
DATA ANALYST and Techniques in Kochi Explore cutting-edge analytical skills ...
DATA ANALYST  and Techniques in Kochi Explore cutting-edge analytical skills ...DATA ANALYST  and Techniques in Kochi Explore cutting-edge analytical skills ...
DATA ANALYST and Techniques in Kochi Explore cutting-edge analytical skills ...
aacj102006
 
Introduction to Artificial Intelligence_ Lec 2
Introduction to Artificial Intelligence_ Lec 2Introduction to Artificial Intelligence_ Lec 2
Introduction to Artificial Intelligence_ Lec 2
Dalal2Ali
 
Time series analysis & forecasting day 2.pptx
Time series analysis & forecasting day 2.pptxTime series analysis & forecasting day 2.pptx
Time series analysis & forecasting day 2.pptx
AsmaaMahmoud89
 
Ad

R data structures-2

  • 1. R Data Structures (Pt. II) WMG Training Sept - Oct 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
  • 4. Data frames • Commonly used R object • You will either: 1. Get a data frame 2. Make your own data frame • Have columns and rows. Usually represent – Columns variables – Rows observations • Each column is actually a vector!
  • 6. Making a data frame • A data frame can be built from scratch inside R using the function data.frame() • Combines vectors with same length • Vectors with different lengths are built using expand.grid() – used for simulations
  • 7. Importing data (simplified) • An important skill • Many datasets are imported as data frames • A useful file format is .csv • Key function is read.table() & its variants • Data can also be imported from other formats e.g. .xls/.xlsx, .spv, .tab,… • Easiest way to start –> save Excel files as CSV • Many useful R packages for diff. data formats
  • 8. Exploring data frames • A few functions – Check dimensions – dim() – View in spreadsheet format – View() – Examine structure – str() – See first/last records – head()/tail() – Summarise variables – summary() – See/set names of variable – colnames() – Check if – is.data.frame() – Change to – as.data.frame() – Make changes to data using edit()
  • 9. Stats brief • Grouping data – tabulation • Measures of central tendency – Mean – Median – Mode • Measures of dispersion – Range, IQR – Variance, Standard deviation
  • 11. Example with Twitter data • Preliminaries – R package called twitteR; access Twitter data – Call install.packages(“twitter”) – Use library(help = “twitteR”) to access package’s DESCRIPTION file – Documentation: help(package = “twitteR”) – Many packages have vignette()s – show you how to use package
  • 12. • More preliminaries – Authenticate i.e. log on through Twitter OAuth – Our details are found in authentication.R – Establish connection with setup_twitter_oauth() • This gives us access to the Twitter data – Download the data with searchTwitter() – Convert to data frame with twListToDF()
  • 15. Subsetting • The $ operator – Look at str() again – Note the $ in the output – You can pick out individual columns with syntax dataframe$columnname – Same thing as a vector – Get to get or set variables
  • 16. > R toolbox > search() > detach() > library() > require() > saveRDS() > readRDS() > file.edit()
  • 17. Homogenous Heterogeneous 1-dimension Atomic vectors Lists 2-dimensions Matrices Data frames N-dimensions Arrays
  翻译: