17
Social Media Analysis using twitteR Mohd Shadab Alam Lead Assistant Manager, Inductis

Social media analysis in R using twitter API

Embed Size (px)

Citation preview

Page 1: Social media analysis in R using twitter API

Social Media Analysis using twitteR

Mohd Shadab AlamLead Assistant Manager,Inductis

Page 2: Social media analysis in R using twitter API

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

Page 3: Social media analysis in R using twitter API

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

Page 4: Social media analysis in R using twitter API

Introduction to twitter APIsTWO APIs: DEFINITION

(a) Stream APITo listen to the live tweets of a user, or

listen to tweets having a particular keyword we use Stream API

(b) REST APIIf we want to retrieve archival data then we

use REST API

Page 5: Social media analysis in R using twitter API

Introduction to twitter APIsAPI 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..

Page 6: Social media analysis in R using twitter API

How to use twitter API in RAUTHENTICATION

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

Page 7: Social media analysis in R using twitter API

How to use twitter API in RAUTHENTICATION

Page 8: Social media analysis in R using twitter API

How to use twitter API in RAUTHENTICATION

NOTE: Do not forget to register the mobile number

Page 9: Social media analysis in R using twitter API

How to use twitter API in RREGISTERATION PROCESS

Required Libraries

install_github("twitteR",username="geoffjentry")

require(twitteR)

setup_twitter_oauth(“f5GhnjWoR17clmd85PMQfjhHO", "QUZlAyj9w9O50TbyYdlNBkV7zILLs4zjhhQFJ2sbBIxhp4Alm2")

Page 10: Social media analysis in R using twitter API

Capturing twitter dataAPI CALL

Sample API calls:

userTimeline('MaxLifeIns', n=3200)

user$getFollowers()

t(sapply(getUser('MaxLifeIns')$getFollowers(), function(x) c(x$name, x$location, x$statusesCount)))

Page 11: Social media analysis in R using twitter API

Capturing twitter dataHOW DATA LOOKS LIKE

C:\Users\shadab\Desktop\twitter\followers

Page 12: Social media analysis in R using twitter API

Google map APIAPI 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")

Page 13: Social media analysis in R using twitter API

Tweets distributionMAP

Page 14: Social media analysis in R using twitter API

Sentiment analysisWORD 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.

Page 15: Social media analysis in R using twitter API

Followers accession diagramThe DIAGRAM

Page 16: Social media analysis in R using twitter API

THOUGHTS!QUESTIONS?

Page 17: Social media analysis in R using twitter API

THANK YOU!!!THANK YOU SLIDE!!!