Which users are the most tweeting your product?

In this post I want to teach you how to see which users talk about something on Twitter and present it in a simple chart. For this example we are going to look at the hashtag #nintendo.

As we saw in another Post , the first thing we have what to do is make the query on Twitter and save it in a data frame.

library(twitteR)
api_key <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
api_secret <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
setup_twitter_oauth(api_key,api_secret)
## [1] "Using browser based authentication"
Query= searchTwitter("#Rstats", geo=NULL)
Result= twListToDF(Query)

We create the user variables, selecting the data frame users and order them from largest to smallest.


Users = table(Result$screenName)
Users_sort= sort(Users, decreasing=T)

To present this data in a visual way we create a color palette with a gradient.

degraded= function (color1, color2, degraded)
{
  library(grDevices)
  palete = colorRampPalette(c(color1, color2))
  palete (degraded)
}
palette = degraded("#033240", "#0895BF", 15)

To be able to visualize this data we are going to create a graph, broken down into three parts: 1 We establish the margins to adjust the image 2 We draw the graph with the 15 most active users. 3 We add a legend explaining the data.


par(mar=c(10,5,2,2), bg="white")
barplot(Users_sort[1:15], las=2, cex.names =1, col=palette )  

Ejemplo de anlisis de usuarios en Twitter

And we get a graphic representation of the users who most Tweet with the hashtag # Rstats.

Summary
Which users are the most tweeting your product?
Article Name
Which users are the most tweeting your product?
Description
An easy way to know which Twitter users are the most talking about a specific hashtag that refers to something that interests us, with a simple script.
Author
Publisher Name
Blog-R
Publisher Logo

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *