Skip to content

Instantly share code, notes, and snippets.

@josep2
Created March 16, 2014 01:33
Show Gist options
  • Save josep2/9577161 to your computer and use it in GitHub Desktop.
Save josep2/9577161 to your computer and use it in GitHub Desktop.
##Load data
Data<-read.csv('twitter_followers.csv')
##Load necessary packages
library(plotly)
##Plotly credentials
p <- plotly(username="USERNAME", key="KEY")
## Histogram of followers tweets
x <- Data$statuses_count
FollowersHistogram = list(
x = x,
type = 'histogramx'
)
p$plotly(FollowersHistogram)
##Get a list of top Locations
TopLocals<-as.data.frame(table(Data$location))
TopLocals<-TopLocals[which(TopLocals$Freq>2),]
TopLocals<-TopLocals[order(-TopLocals$Freq),]
TopLocals = TopLocals[-1,]
#Make a bar chart
BarLabels<-list(
x=TopLocals$Var1,
y=TopLocals$Freq,
type='bar',
text=TopLocals$Var1,
marker=list(
color='rgb(236,145,9)'
)
)
p$plotly(BarLabels)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment