# Created by Matt Asher for statisticsblog.com # Feel free to share and modify so long as this header remains playlist = read.table("/path/to/playlist.txt", sep="\t") pTable = data.frame(table(playlist[,1])) pTable = pTable[ order(-pTable[,2]),] HTMLfile="/path/to/save/popchart.html" toWrite = '' toWrite = paste(toWrite, "", "\n") # Create HTML bar proportional to times played maxPlayed = max(pTable[,2]) # How wide should the widest bar be in pixels maxBarWidth = 60 for(m in 1:dim(pTable)[1]) { toWrite = paste(toWrite, '') toWrite = paste(toWrite, '', sep="") toWrite = paste(toWrite, '') toWrite = paste(toWrite, '') } toWrite = paste(toWrite, "
  ', sep="") toWrite = paste(toWrite, pTable[m,1], "\n") toWrite = paste(toWrite, '') toWrite = paste(toWrite, '
", "\n") write(toWrite, file=HTMLfile)