Twitter Analysis Using R

PREREQUISITES:

  1. You have already installed R and are using RStudio.
  2. In order to extract tweets, you will need a Twitter application and hence a Twitter account. If you don’t have a Twitter account, please sign up.
  3. Use your Twitter login ID and password to sign in at Twitter Developers.

1.  STEPS TO CREATE A TWITTER APPLICATION

a.  Navigate to My Applications in the upper right hand corner.
b.  Navigate to My Applications in the upper right hand corner.

c.  Create a new application.

d.  Fill out the new app form. Names should be unique, i.e., no one else should have used this name for their Twitter app. Give a brief description of the app. You can change this later on if needed. Enter your website or blog address. Callback URL can be left blank. Once you’ve done this, make sure you’ve read the “Developer Rules Of The Road” blurb, check the “Yes, I agree” box, fill in the CAPTCHA and click the “Create Your Twitter Application” button.


e.  Scroll down and click on “Create my access token” button.


f.  Note the values of consumer key and consumer secret and keep them handy for future use. You should keep these secret. If anyone was to get these keys, they could effectively access your Twitter account.


2.  INSTALL AND LOAD R PACKAGES



> install.packages(c("devtools", "rjson", "bit64", "httr"))

> library(devtools)
> install_github("twitteR", username="geoffjentry")
> library(twitteR)
> api_key <-"qEnZS3fEoYBiJViIVGgZkVHZZ"
> api_secret <-"bV0lchfjaiiYURRLGTknJVrHgvyYsiv2x9gCXNnCgc4FuHMiHy"
> access_token <-"827096440111505408-jdLpiu4ys14qEy7goYe5cd4wYqN0Xk6"
> access_token_secret <-"ZWEyrRezGB1G1vf1nPjC4xp8zrXpnHSNBnXb1GqXix6dT"
> setup_twitter_oauth(api_key,api_secret)

[1] "Using browser based authentication"
Use a local file ('.httr-oauth'), to cache OAuth access credentials between R sessions?

1: Yes
2: No

Selection: no
Enter an item from the menu, or 0 to exit
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort

Authentication complete.



once Authentication is Complete ,you can search Tweets by using.

> searchTwitter("iphone")

so you pull tweets some thing like this!!!!



[1] "ro2VI7hBe1nPbFf: RT @yuttoku_aaa_59: Lock Screen (iPhone ver)\n\n発売を記念して作りました! !\n\n沢山の方に気に入ってもらえるといいな。\n\n4枚目に書いてあるので見てください。\n手書き下手ですみません\xed\xa0\xbd\xed\xb9\x87\n\n#AAA\n#MAGIC https://t…"

[2] "reinbocase: เคสแข็งเปิดบนล่าง งานสวยมาก มี2สี\niphone 5,5s,se,6,6s,6+,6s+,7,7+\nPrice : 220\n#งานสวย #งานดี #เคสงานดี #ของดีสมราคาhttps://t.co/OmTa11o9yO"

[3] "SellMyMobileUK: IPhone 7 Plus (128GB - Locked) - £515.69 https://t.co/pQVlKNACtb"

[4] "PookThanaporn: RT @yoware: ใครเล็ง iPhone 8 ปีนี้ ต้องเก็บหอมรอมริบให้หนักและเนิ่น เพราะข่าวลือบอกราคาเริ่มต้นเกิน $1,000 แววเฉียด 40,000 บาท\n\nhttps://t.c…"

[5] "Babuuui_daruuun: モイ!iPhoneからキャス配信中 -いちごとコラボ https://t.co/d6aSqPuhs8"

That's it !! ...Start Analysing  and have fun !!!


Thanks,

Have Fun!!!!


Please Leave your Comment Below If you Have Any Clarifications Regarding Installations or Any Suggestions.

Comments

Popular posts from this blog

Quick Setup Steps For Installing & Integrating Spark,Hive,Hadoop Processess Together !!!

Best Practices for Apache Hive Performance Tuning

Performance Improvement in Hive (Properties in HIVE -SITE.XML)

Installation Steps for Hive

Installation Steps For MySql Server (version 5.7.23) For Centos

Facebook Data Analysis Using R

Installation Steps For Spark