SlideShare a Scribd company logo
Social Media
Analysis using
twitteR
Mohd Shadab Alam
Lead Assistant Manager,
Inductis
What will be covered?
• Introduction to twitter APIs
• How to use twitter APIs in R
• Capturing twitter data
• Google map API
• Tweets Distribution
• Sentiment analysis using twitter data
• Followers accession diagram
Introduction to twitter APIs
• API stands for application interface
“a set of functions and procedures that allow the
creation of applications which access the
features or data of an operating system,
application, or other service”
• Two of the most commonly used
APIs are:
(a) Stream API
(b) REST API
GENERAL INTRODUCTION
Introduction to twitter APIs
TWO APIs: DEFINITION
(a) Stream API
To listen to the live tweets of a user, or
listen to tweets having a particular keyword
we use Stream API
(b) REST API
If we want to retrieve archival data then we
use REST API
Introduction to twitter APIs
API input/output structure
INPUT OUTPUT
User name tweet
Key word Time
Date range Lat long (geo coding)
Lat long range followers
Language retweets
and so on… and so on..
How to use twitter API in R
AUTHENTICATION
We need to log into the twitter
developer account to set up an
authentication channel
dev.twitter.com
Secure authentication key and
password are needed before we
can start using the APIs
How to use twitter API in R
AUTHENTICATION
How to use twitter API in R
AUTHENTICATION
NOTE: Do not forget to register the mobile number
How to use twitter API in R
REGISTERATION PROCESS
Required Libraries
install_github("twitteR",username="geo
ffjentry")
require(twitteR)
setup_twitter_oauth(“f5GhnjWoR17clm
d85PMQfjhHO",
"QUZlAyj9w9O50TbyYdlNBkV7zILLs4
zjhhQFJ2sbBIxhp4Alm2")
Capturing twitter data
API CALL
Sample API calls:
userTimeline('MaxLifeIns', n=3200)
user$getFollowers()
t(sapply(getUser('MaxLifeIns')
$getFollowers(), function(x) c(x$name,
x$location, x$statusesCount)))
Capturing twitter data
HOW DATA LOOKS LIKE
C:Usersshadab
Desktoptwitterfollowers
Google map API
API CALL
Sample API calls:
require(ggmap)
map <- get_map(location = 'India',
zoom = 4)
points <- data.frame(x =
as.numeric(loci$lon), y =
as.numeric(loci$lat))
ggmap(map) + geom_point(data =
points, aes(x = x, y = y), size = 3,
alpha = 1/3, color = "darkblue")
Tweets distribution
MAP
Sentiment analysis
WORD CLOUD
Positive Negative
win poor
appreciable worst
performer decrease
increase loose
nice not
and so on… and so on..
Corpus is created and word is replaced with the stem word like
running is replaced with “run” etc. Frequency of positive and
negative words are counted to mark a sentence as positive or negative.
Followers accession diagram
The DIAGRAM
THOUGHTS!
QUESTIONS?
THANK YOU!!!
THANK YOU SLIDE!!!

More Related Content

Similar to Social media analysis in R using twitter API (20)

PPTX
Harvesting Data from Twitter Workshop: Hands-on Experience
ASA_Group
 
PDF
CSE5656 Complex Networks - Gathering Data from Twitter
Marcello Tomasini
 
PPTX
Twitter api
kaleem malick
 
PPTX
R Class: Set up Social Media API
Weiai Wayne Xu
 
PDF
Mining Georeferenced Data
Bruno Gonçalves
 
PDF
Twitter data analysis using r (part 2)
santoshi mangalgi
 
PDF
Unleashing Twitter Data for Fun and Insight
Matthew Russell
 
PDF
Unleashing twitter data for fun and insight
Digital Reasoning
 
PPT
Twitter API Trends (Pubcon 2009)
ayb
 
ODP
Twitter
Rajesh Barri
 
PPTX
Twitter_Sentiment_analysis.pptx
JOELFRANKLIN13
 
KEY
Twitter API 2.0
Alex Payne
 
PDF
Social Media Mining using R
Subhankar Mishra
 
PDF
FInal Project Intelligent Social Media Analytics
Ashwin Dinoriya
 
PPTX
Text Mining of Twitter in Data Mining
Meghaj Mallick
 
PPTX
Twitter sentiment analysis ppt
SonuCreation
 
PPT
John Conroy
blogtalk
 
PDF
RDataMining slides-text-mining-with-r
Yanchang Zhao
 
PDF
20130504 - FeWeb - Twitter API
Pascal Alberty
 
PDF
Querying open data with R - Talk at April SheffieldR Users Gp
Paul Richards
 
Harvesting Data from Twitter Workshop: Hands-on Experience
ASA_Group
 
CSE5656 Complex Networks - Gathering Data from Twitter
Marcello Tomasini
 
Twitter api
kaleem malick
 
R Class: Set up Social Media API
Weiai Wayne Xu
 
Mining Georeferenced Data
Bruno Gonçalves
 
Twitter data analysis using r (part 2)
santoshi mangalgi
 
Unleashing Twitter Data for Fun and Insight
Matthew Russell
 
Unleashing twitter data for fun and insight
Digital Reasoning
 
Twitter API Trends (Pubcon 2009)
ayb
 
Twitter
Rajesh Barri
 
Twitter_Sentiment_analysis.pptx
JOELFRANKLIN13
 
Twitter API 2.0
Alex Payne
 
Social Media Mining using R
Subhankar Mishra
 
FInal Project Intelligent Social Media Analytics
Ashwin Dinoriya
 
Text Mining of Twitter in Data Mining
Meghaj Mallick
 
Twitter sentiment analysis ppt
SonuCreation
 
John Conroy
blogtalk
 
RDataMining slides-text-mining-with-r
Yanchang Zhao
 
20130504 - FeWeb - Twitter API
Pascal Alberty
 
Querying open data with R - Talk at April SheffieldR Users Gp
Paul Richards
 

Recently uploaded (10)

PPTX
DIFFERENT TYPES OF TOPICAL FORMULATIONS.pptx
NighatJaved2
 
PDF
Creative Social Media Campaign Strategies That Inspire Action.pdf
revathimsr06
 
PPTX
Top Questions to Ask Before Hiring a Social Media Agency in Chicago
Moz Web Media
 
PPTX
How Discursive Alliances Shift: A Longitudinal Analysis of Australian Climate...
Axel Bruns
 
PDF
the concept and the pdf of a seo course.pdf
r62544400
 
PDF
un mundo lleno de datos que lo cambia todo
JorgeSilesCabrera1
 
PDF
Your LinkedIn Success Partner Get Real Followers Now
SocioCosmos
 
PDF
Pride Month 2025: Engagement, Sentiment & Digital Silence
PRophet
 
PPTX
Social Media & Research Dissemination - REPORT IN PUBLICATION.V2.pptx
arvielobos1
 
PDF
2025’s Best Posting Schedule for Facebook, Instagram, LinkedIn & More.pdf
ManojNegi
 
DIFFERENT TYPES OF TOPICAL FORMULATIONS.pptx
NighatJaved2
 
Creative Social Media Campaign Strategies That Inspire Action.pdf
revathimsr06
 
Top Questions to Ask Before Hiring a Social Media Agency in Chicago
Moz Web Media
 
How Discursive Alliances Shift: A Longitudinal Analysis of Australian Climate...
Axel Bruns
 
the concept and the pdf of a seo course.pdf
r62544400
 
un mundo lleno de datos que lo cambia todo
JorgeSilesCabrera1
 
Your LinkedIn Success Partner Get Real Followers Now
SocioCosmos
 
Pride Month 2025: Engagement, Sentiment & Digital Silence
PRophet
 
Social Media & Research Dissemination - REPORT IN PUBLICATION.V2.pptx
arvielobos1
 
2025’s Best Posting Schedule for Facebook, Instagram, LinkedIn & More.pdf
ManojNegi
 
Ad

Social media analysis in R using twitter API

  • 1. Social Media Analysis using twitteR Mohd Shadab Alam Lead Assistant Manager, Inductis
  • 2. What will be covered? • Introduction to twitter APIs • How to use twitter APIs in R • Capturing twitter data • Google map API • Tweets Distribution • Sentiment analysis using twitter data • Followers accession diagram
  • 3. Introduction to twitter APIs • API stands for application interface “a set of functions and procedures that allow the creation of applications which access the features or data of an operating system, application, or other service” • Two of the most commonly used APIs are: (a) Stream API (b) REST API GENERAL INTRODUCTION
  • 4. Introduction to twitter APIs TWO APIs: DEFINITION (a) Stream API To listen to the live tweets of a user, or listen to tweets having a particular keyword we use Stream API (b) REST API If we want to retrieve archival data then we use REST API
  • 5. Introduction to twitter APIs API input/output structure INPUT OUTPUT User name tweet Key word Time Date range Lat long (geo coding) Lat long range followers Language retweets and so on… and so on..
  • 6. How to use twitter API in R AUTHENTICATION We need to log into the twitter developer account to set up an authentication channel dev.twitter.com Secure authentication key and password are needed before we can start using the APIs
  • 7. How to use twitter API in R AUTHENTICATION
  • 8. How to use twitter API in R AUTHENTICATION NOTE: Do not forget to register the mobile number
  • 9. How to use twitter API in R REGISTERATION PROCESS Required Libraries install_github("twitteR",username="geo ffjentry") require(twitteR) setup_twitter_oauth(“f5GhnjWoR17clm d85PMQfjhHO", "QUZlAyj9w9O50TbyYdlNBkV7zILLs4 zjhhQFJ2sbBIxhp4Alm2")
  • 10. Capturing twitter data API CALL Sample API calls: userTimeline('MaxLifeIns', n=3200) user$getFollowers() t(sapply(getUser('MaxLifeIns') $getFollowers(), function(x) c(x$name, x$location, x$statusesCount)))
  • 11. Capturing twitter data HOW DATA LOOKS LIKE C:Usersshadab Desktoptwitterfollowers
  • 12. Google map API API CALL Sample API calls: require(ggmap) map <- get_map(location = 'India', zoom = 4) points <- data.frame(x = as.numeric(loci$lon), y = as.numeric(loci$lat)) ggmap(map) + geom_point(data = points, aes(x = x, y = y), size = 3, alpha = 1/3, color = "darkblue")
  • 14. Sentiment analysis WORD CLOUD Positive Negative win poor appreciable worst performer decrease increase loose nice not and so on… and so on.. Corpus is created and word is replaced with the stem word like running is replaced with “run” etc. Frequency of positive and negative words are counted to mark a sentence as positive or negative.