HoF WAR R code
abap
posted: Aug, 12th 2009 | jump to bottom
p3_name<-'Dick Allen' p4_name<-'Harmon Killebrew' p1_war<-c(-0.3,0.3,1.3,3.5,9,6.8,3,0,0.3,1.6,3.6,2.7,4,2.6,2.2,4.5,1.4,3.6,2.9,4.9,0.5,-1.1) p2_war<-c(0,0.3,0.5,4.5,6.5,4.1,4.7,4.2,4.6,7.4,4.9,5.9,3,1.2,1.9,0.6,2.2,3.1,0.1,-0.1,-0.6) p3_war<-c(0.1,9.1,5.9,7.8,5.9,4.4,4,2.4,5.9,9.3,2.7,3.5,-0.9,0.8,0.3) p4_war<-c(-0.1,-0.2,-0.5,0.2,-0.3,4,3.4,5.5,2.7,4.3,4.3,4.7,6,7.1,2.4,6.1,5.8,3.4,2.8,0.3,-0.5,-0.3) png('~/Documents/hof_war.png',height=500,width=500) par(cex=1.75,bty='n',mgp=c(2,0,0),mai=c(0.5,0.5,0.5,0.5)) x1<-1 x2<-max(length(p1_war),length(p2_war),length(p3_war),20) y1<-min(p1_war,p2_war,p3_war,0) y2<-max(p1_war,p2_war,p3_war,10) plot(1, 7.5, col='white', type='l', xlim=c(x1,x2), ylim=c(y1,y2), xaxt='n', yaxt='n', lwd=3) mtext('Best to Worst Years',side=1,line=0,cex=1.75) mtext('Wins Above Replacement',side=2,line=0,cex=1.75) polygon(c(1,1,17,20), c(8.2,7.2,0,0), col='gray', density=100) text(c(18,18,18,18), seq(from=9.5,to=8,length=4), col=c('orange','black','red','blue'), labels=c(p1_name,p2_name,p3_name,p4_name), cex=0.8, adj=1) lines(sort(p1_war,decreasing=TRUE), col='orange', lwd=5) lines(sort(p2_war,decreasing=TRUE), col='black', lwd=5) lines(sort(p3_war,decreasing=TRUE), col='red', lwd=5) lines(sort(p4_war,decreasing=TRUE), col='blue', lwd=5) dev.off()
433 views




