SlideShare a Scribd company logo
R project(Analyze Twitter with R)
Requirements
 Library: twitteR
o Provides an interface to the Twitter web API.
 R is an open source programming language and
software environment for statistical computing and
graphics
 RStudio:RStudio is a free and open source
integrated development environment (IDE) for R
Steps
1. Signup in twitter
2. Go to apps.twitter.com and register Application
Program Interface(API) using twitter account
3. Get API Key, API Secret, Access Token, Access
Token Secret
1. API KEY:JfpQuWXgr9YVhi1TeYzGLagKy
2. API Secret:
Ao8afu033PQMslxsLvKMdgVhIFRMiV9Ie2ppXg3oB
eIvF0ZnZz
3. Access Token: 927320525285634049-
dOhOiQFH708QVJeslJfqVnYgKxxe5mu
4. Access Token Secret:
JYQKFhsMjlI8xid8ozVerRfHSq8KrpZFky5m9vFh3ox
4. Install Twitter Library
1. install. packages("twitteR") or
5. Set twitteR library
1. Load: library(twitteR)
2. setup_twitter_oauth(api_key,api_secret,access_toke
n,access_token_secret)
Demo1: Text Mining with WordCloud
 install. Packages(“tm”)
install. packages(“wordcloud”)
library(“twitteR”)
library(“tm”)
library(“ROAuth”)
library(“wordcloud”)
>ref<-searchTwitter(“Himalayas”, n=100,lang=“en”)
>ref_samp<-sapply(ref, function(x), x$getText())
ref_corpus(vectorsource(ref_samp))
 inspect(ref_corpus)
 ref_samp<-tm_map(ref_corpus,
removepunctuation)
 ref_samp<-tm_map(ref_samp,
content_transformer(tolower))
 ref_samp<-tm_map(ref_samp, removewords,
stopwards((“english”))
R project(Analyze Twitter with R)
Demo2:Text Mining with R – an Analysis of Twitter Data
 >unstructured data
 >text categorization
text clustering
 entity extraction
Text Mining process
extract data from Twitter
clean extracted data and build a document-term matrix
find frequent words and associations
create a word cloud to visualize important words
text clustering
Retrieve Tweets
 searchTwitter("hello World", since='2017-11-01',
until='2017-11-8')
 jalandhar<-
searchTwitter("thursday",geocode='31.326,75.5762,5
mi')
 japan<-
searchTwitter("thursday",geocode='35.6895,139.691
7,5mi')
 a<-c(length(j),length(z))
R project(Analyze Twitter with R)
R project(Analyze Twitter with R)
Demo 3: Getting Trends
 Trends <- availableTrendLocations()
 head(trend)
 Trends
 World<-getTrends()
 length(intersect(World[[1]], l[[1]]))
 mat=matrix(nrow = 2 ,ncol = 2)
mat[[1,1]]=length(intersect(World[[1]], World[[1]]))
mat[[1,2]]=length(intersect(World[[1]], l[[1]]))
mat[[2,1]]=length(intersect(l[[1]], World[[1]]))
mat[[2,2]]=length(intersect(l[[1]], l[[1]]))
R project(Analyze Twitter with R)
R project(Analyze Twitter with R)
Thank You

More Related Content

PPT
Social media analysis in R using twitter API
PDF
Twitter APIs - the starter guide
PDF
How To Use IFTTT For Social Media Automation
DOCX
Twitter analysis by Kaify Rais
PDF
Twitter data analysis using r (part 2)
PPTX
Harvesting Data from Twitter Workshop: Hands-on Experience
PPTX
R Class: Set up Social Media API
PPTX
Text Mining of Twitter in Data Mining
Social media analysis in R using twitter API
Twitter APIs - the starter guide
How To Use IFTTT For Social Media Automation
Twitter analysis by Kaify Rais
Twitter data analysis using r (part 2)
Harvesting Data from Twitter Workshop: Hands-on Experience
R Class: Set up Social Media API
Text Mining of Twitter in Data Mining

Similar to R project(Analyze Twitter with R) (7)

PPTX
Twitter_Sentiment_analysis.pptx
PDF
Question 1 when i run the following program I am getting an.pdf
PDF
Jordan Kay's Twitter API tour
PPTX
Development of Twitter Application #3 - OAuth
DOCX
Sentiment analysis- Modi, Trump, Putin
PDF
Social Media Mining using R
PDF
Mining Georeferenced Data
Twitter_Sentiment_analysis.pptx
Question 1 when i run the following program I am getting an.pdf
Jordan Kay's Twitter API tour
Development of Twitter Application #3 - OAuth
Sentiment analysis- Modi, Trump, Putin
Social Media Mining using R
Mining Georeferenced Data
Ad

Recently uploaded (20)

PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
web development for engineering and engineering
PDF
PPT on Performance Review to get promotions
PPTX
Construction Project Organization Group 2.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Welding lecture in detail for understanding
PPTX
Geodesy 1.pptx...............................................
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Operating System & Kernel Study Guide-1 - converted.pdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Lecture Notes Electrical Wiring System Components
Internet of Things (IOT) - A guide to understanding
web development for engineering and engineering
PPT on Performance Review to get promotions
Construction Project Organization Group 2.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
bas. eng. economics group 4 presentation 1.pptx
OOP with Java - Java Introduction (Basics)
Welding lecture in detail for understanding
Geodesy 1.pptx...............................................
Ad

R project(Analyze Twitter with R)

  • 2. Requirements  Library: twitteR o Provides an interface to the Twitter web API.  R is an open source programming language and software environment for statistical computing and graphics  RStudio:RStudio is a free and open source integrated development environment (IDE) for R
  • 3. Steps 1. Signup in twitter 2. Go to apps.twitter.com and register Application Program Interface(API) using twitter account 3. Get API Key, API Secret, Access Token, Access Token Secret 1. API KEY:JfpQuWXgr9YVhi1TeYzGLagKy 2. API Secret: Ao8afu033PQMslxsLvKMdgVhIFRMiV9Ie2ppXg3oB eIvF0ZnZz 3. Access Token: 927320525285634049- dOhOiQFH708QVJeslJfqVnYgKxxe5mu 4. Access Token Secret: JYQKFhsMjlI8xid8ozVerRfHSq8KrpZFky5m9vFh3ox
  • 4. 4. Install Twitter Library 1. install. packages("twitteR") or 5. Set twitteR library 1. Load: library(twitteR) 2. setup_twitter_oauth(api_key,api_secret,access_toke n,access_token_secret)
  • 5. Demo1: Text Mining with WordCloud  install. Packages(“tm”) install. packages(“wordcloud”) library(“twitteR”) library(“tm”) library(“ROAuth”) library(“wordcloud”)
  • 6. >ref<-searchTwitter(“Himalayas”, n=100,lang=“en”) >ref_samp<-sapply(ref, function(x), x$getText()) ref_corpus(vectorsource(ref_samp))  inspect(ref_corpus)  ref_samp<-tm_map(ref_corpus, removepunctuation)  ref_samp<-tm_map(ref_samp, content_transformer(tolower))  ref_samp<-tm_map(ref_samp, removewords, stopwards((“english”))
  • 8. Demo2:Text Mining with R – an Analysis of Twitter Data  >unstructured data  >text categorization text clustering  entity extraction Text Mining process extract data from Twitter clean extracted data and build a document-term matrix find frequent words and associations create a word cloud to visualize important words text clustering
  • 9. Retrieve Tweets  searchTwitter("hello World", since='2017-11-01', until='2017-11-8')  jalandhar<- searchTwitter("thursday",geocode='31.326,75.5762,5 mi')  japan<- searchTwitter("thursday",geocode='35.6895,139.691 7,5mi')  a<-c(length(j),length(z))
  • 12. Demo 3: Getting Trends  Trends <- availableTrendLocations()  head(trend)  Trends  World<-getTrends()  length(intersect(World[[1]], l[[1]]))  mat=matrix(nrow = 2 ,ncol = 2) mat[[1,1]]=length(intersect(World[[1]], World[[1]])) mat[[1,2]]=length(intersect(World[[1]], l[[1]])) mat[[2,1]]=length(intersect(l[[1]], World[[1]])) mat[[2,2]]=length(intersect(l[[1]], l[[1]]))