WhatsApp Chat Sentiment Analysis in R

How to Analyse the popularity of hashtags on Instagram | Nike Vs Puma | R Programming

How to Analyse the popularity of hashtags on Instagram

Objective: To Analyse the popularity of two hashtags on Instagram using R programming. 

Step 1 : Install and load required package

We need to install instaR to analyse and setup oauth for the purpose of analysing hastags.

Follow the following commands
> install.packages("instaR")
> library(instaR)

Step 2: Get access to Instagram for developers Client ID and Key

Before we start Oauth set up we need to get access to developers account on Instagram. Which can set up within minutes.
Follow the following steps
1. Open this link in your browser https://www.instagram.com/developer/

2. Click on the Log In in the right hand corner and log in with your regular Instagram account

3. Click on the "Register Your Application" button and follow all the steps and click on register.

4. Click on the manage clients and you will see the following window. click on the manage option.

5. Note down the unique Client ID and Secret and click on the security tab.

6. Copy and paste this URL in the Valid redirect URLS and click on update client.


Step 3: Set up Oauth and Authorisation.

Just copy paste this code with your client id and password to get 

> my_client_id <- "4************************"
> my_client_secret <- "ac********************"
> my_oauth <- instaOAuth(my_client_id,  my_client_secret,  scope = c("basic","public_content"))

You will get the following message.
> my_oauth<-instaOAuth(my_client_id,  my_client_secret,  scope = c("basic","public_content"))
Copy and paste into 'OAuth redirect_uri' on Instagram App Settings: http://localhost:1410/ 
When done, press any key to continue...

Once you press any key, you will get following message in your browser.

"Authentication complete. Please close this page and return to R."

Step 4: Save and load the Oauth.

Use the following command to save and load.
> save(my_oauth, file = "my_oauth")
> load("my_oauth")

Step 5: Use the getTagCount function to find how many times a tag has been used.

Just use the following command to find the number of time a tag has been used on instagram.
> nike_tagcount <- getTagCount(tag = "nike", token = my_oauth)
> puma_tagcount <- getTagCount(tag = "puma", token = my_oauth)


As you can see Nike tag is clearly more popular than Puma on Instagram as its used more by the users.