Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#read in data
final<-read.csv("outputFile.txt", header=FALSE)[,-c(1,2)]
original<-read.csv("zep_tracks.csv", header=FALSE)
#join together
merged<-merge(original, final, by.x="V5", by.y="V7")
#grab key vars and fix labels
plotdata<-merged[,c("V5", "V7", "V3.x", "V21.x", "V25", "V26", "V27")]
colnames(plotdata)<-c("Track", "Track_Position", "Album", "Length", "KMeans", "BKM", "GMM")
plotdata$Album <- factor(plotdata$Album, levels = c("Led Zeppelin", "Led Zeppelin II", "Led Zeppelin III", "Led Zeppelin IV", "Houses Of The Holy", "Physical Graffiti", "Presence", "In Through The Out Door", "Coda"))
plotdata$Track_Position<-paste0("Track_", plotdata$Track_Position)
plotdata$Track_Position <- factor(plotdata$Track_Position, levels = paste0("Track_", 1:15))
plot_ly(plotdata, x = ~Album, y = ~Track_Position, text = ~Track, type = 'scatter', mode = 'markers',
size = ~Length/1000/60, color = as.factor(plotdata$KMeans), colors = brewer.pal(9,"Set1"),
marker = list(opacity = 0.8, sizemode = 'diameter', sizeref=3)) %>%
layout(title = 'Led Zeppelin Tracks',
xaxis = list(showgrid = FALSE, showticklabels=TRUE, title="", type = "category"),
yaxis = list(showgrid = FALSE, showticklabels=FALSE, title="", type = "category"),
showlegend = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.