Created
January 21, 2016 07:24
-
-
Save tslumley/040749c559bb71d1921b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rock<-read.csv("~/Downloads/output.csv", as.is=TRUE, header=FALSE, col.names=c("datetime","song","group")) | |
rock$stime<-substr(rock$datetime,5,9) | |
rock$timeangle<-with(rock, as.numeric(substr(stime,1,2))*2*pi/24+as.numeric(substr(stime,4,5))*2*pi/24/60) | |
rock$ty<-cos(rock$timeangle) | |
rock$tx<-sin(rock$timeangle) | |
rock$txmean<-mean(rock$tx) | |
rock$tymean<-mean(rock$ty) | |
groups<-aggregate(rock[,c("tx","ty","txmean","tymean")],list(rock$group),sum) | |
groups$plays<-groups$txmean/rock$txmean[1] | |
groups$playscale<-groups$plays/max(groups$plays) | |
plot(I(ty)~I(tx),data=groups,pch=21,bg=gray(1-playscale),axes=F,xlab="",ylab="",xlim=c(-18,5),ylim=c(-18,5)) | |
mtext("midnight",3) | |
mtext("noon",1) | |
mtext("morning",4) | |
mtext("afternoon",2) | |
abline(h=0,lty=2,col="darkred") | |
abline(v=0,lty=2,col="darkred") | |
with(groups, identify(tx,ty,labels=as.character(Group.1),col="blue")) | |
plot(I(ty-tymean)~I(tx-txmean),data=groups,pch=21,bg=gray(1-playscale),axes=F,xlab="",ylab="",xlim=c(-6,6),ylim=c(-6,6)) | |
mtext("midnight",3) | |
mtext("noon",1) | |
mtext("morning",4) | |
mtext("afternoon",2) | |
abline(h=0,lty=2,col="darkred") | |
abline(v=0,lty=2,col="darkred") | |
with(groups, identify(tx-txmean,ty-tymean,labels=as.character(Group.1),col="blue")) | |
plot(I((ty-tymean)/sqrt(plays))~I((tx-txmean)/sqrt(plays)),data=groups,pch=21,bg=gray(1-playscale),axes=F,xlab="",ylab="",xlim=c(-3,3),ylim=c(-3,3)) | |
mtext("midnight",3) | |
mtext("noon",1) | |
mtext("morning",4) | |
mtext("afternoon",2) | |
abline(h=0,lty=2,col="darkred") | |
abline(v=0,lty=2,col="darkred") | |
with(groups, identify((tx-txmean)/sqrt(plays),(ty-tymean)/sqrt(plays),labels=as.character(Group.1),col="blue")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment