Skip to content

Instantly share code, notes, and snippets.

@josep2
Created February 25, 2014 01:08
Show Gist options
  • Save josep2/9200638 to your computer and use it in GitHub Desktop.
Save josep2/9200638 to your computer and use it in GitHub Desktop.
#Load Necssary packages
library(plotly)
#Upload the CSV
pitchfork<-read.csv('pitchfork_review_data.csv')
##Make a Best New Music Set
Special<-pitchfork[which(pitchfork$accolade==" Best New Music "), ]
#plotly credentials
p <- plotly(username="yourname", key="yourkey")
#Create Bubble Chart
OverTime<- list(
x=Special$publish_date,
y=Special$score,
text=Special$album,
type="scatter",
mode="markers",
marker=list(
color = 'rgb(133, 39, 215)',
"size"=12
)
)
p$plotly(OverTime)
## Get a dataframe of the top record labels
InitialLabels<-as.data.frame(table(Special$label))
#We'll pick those with more than 3
TopLabels<-InitialLabels[which(InitialLabels$Freq > 3), ]
##Sort it descending
TopLabels<-TopLabels[order(-TopLabels$Freq),]
##Check Artists who have the honor most
InitialArts<-as.data.frame(table(Special$artist))
##More Than twice will be our indication
TopArtist<-InitialArts[which(InitialArts$Freq > 2), ]
#Descend
TopArtist<-TopArtist[order(-TopArtist$Freq),]
#Make a bar chart
BarLabels<-list(
x=TopLabels$Var1,
y=TopLabels$Freq,
type='bar',
text=TopLabels$Var1,
marker=list(
color='rgb(236,145,9)'
)
)
p$plotly(BarLabels)
### Same Bar chart for artists, just change the color
BarArts<-list(
x=TopArtist$Var1,
y=TopArtist$Freq,
type='bar',
text=TopArtist$Var1,
marker=list(
color='rgb(9,153,236)'
)
)
p$plotly(BarArts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment