Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass[]{article}
- \usepackage{setspace,relsize,comment,Sweave}
- \setlength{\oddsidemargin}{0.35cm}
- \setlength{\evensidemargin}{0.35cm}
- \setlength{\textwidth}{16.2cm}
- \setlength{\topmargin}{-1cm}
- \setlength{\headsep}{0cm}
- \setlength{\textheight}{23.4cm}
- \SweaveOpts{prefix.string=graphics/}
- \title{Biostat -- Fantasy Football 2010}
- \author{Tatsuki Koyama and Will Gray}
- \begin{document}
- \maketitle
- <<echo=f>>=
- library(VICCBiostat)
- source('func.r')
- how.many.to.display <- 20 # for miscellaneous informtion.
- ## Data ##
- sco <- as.matrix(read.csv('points.csv'))
- sch <- as.matrix(read.csv('schedule.csv'))
- div <- as.matrix(read.csv('divisions.csv'))[1,]
- ord <- order(colnames(sco))
- gd <- gamesData(sco, sch, div)
- st <- standings(gd, div)
- gd <- gd[,!(colnames(gd) %in% 'divg')]
- sco <- sco[,ord]
- sch <- sch[,ord]
- @
- \section*{Week 1 to Week 13}
- \subsection*{Standings}
- <<echo=f>>=
- st
- @
- \newpage
- \subsection*{By Points}
- <<echo=f>>=
- order2(st, c('pts'), decreasing=c(TRUE))
- @
- \subsection*{By Expected Wins}
- <<echo=f>>=
- order2(st, c('e.wins','pts'), decreasing=c(TRUE,TRUE))
- @
- \newpage
- \subsection*{By Luck}
- <<echo=f>>=
- order2(st, c('luck','pts'), decreasing=c(TRUE,TRUE))
- @
- \subsection*{By Imaginary Defense}
- <<echo=f>>=
- order2(st, c('opp.pts','pts'), decreasing=c(FALSE,TRUE))
- @
- <<echo=f>>=
- h <- how.many.to.display
- wins <- gd[gd$worl == 'Win',]
- loss <- gd[gd$worl == 'Loss',]
- @
- \newpage
- \section*{Miscellaneous Information}
- \subsection*{The highest points}
- <<echo=f>>=
- data.frame(gd[with(gd, order(pts, decreasing=TRUE)),][1:h, ], row.names=1:h)
- @
- \subsection*{The lowest points}
- <<echo=f>>=
- data.frame(gd[with(gd, order(pts, decreasing=FALSE)),][1:h, ], row.names=1:h)
- @
- \newpage
- \subsection*{The lowest points to win a game}
- <<echo=f>>=
- data.frame(wins[with(wins, order(pts, decreasing=FALSE)),][1:h, ], row.names=1:h)
- @
- \subsection*{The highest points to lose a game}
- <<echo=f>>=
- data.frame(loss[with(loss, order(pts, decreasing=TRUE)),][1:h, ], row.names=1:h)
- @
- \newpage
- \subsection*{The lowest rank to win a game}
- <<echo=f>>=
- data.frame(wins[with(wins, order(rank, decreasing=TRUE)),][1:h, ], row.names=1:h)
- @
- \subsection*{The highest rank to lose a game}
- <<echo=f>>=
- data.frame(loss[with(loss, order(rank, decreasing=FALSE)),][1:h, ], row.names=1:h)
- @
- \newpage
- \subsection*{The most lopsided games by points}
- <<echo=f>>=
- data.frame(wins[with(wins, order(diff.pts, decreasing=TRUE)),][1:h, ], row.names=1:h)
- @
- \subsection*{The closest games by points}
- <<echo=f>>=
- data.frame(wins[with(wins, order(diff.pts, decreasing=FALSE)),][1:h, ], row.names=1:h)
- @
- \newpage
- \subsection*{The most lopsided games by ratio}
- <<echo=f>>=
- data.frame(wins[with(wins, order(-ratio, decreasing=FALSE)),][1:h, ], row.names=1:h)
- @
- \subsection*{The closest games by ratio}
- <<echo=f>>=
- data.frame(wins[with(wins, order(-ratio, decreasing=TRUE)),][1:h, ], row.names=1:h)
- @
- \begin{center}
- <<echo=f, fig=t, height=12, width=8>>=
- plotExpectedWins(sco)
- @
- \subsection*{}
- <<echo=f, fig=t, height=12, width=10>>=
- plotWinsDistribution(sco)
- @
- \subsection*{}
- <<echo=f, fig=t, height=12, width=8>>=
- tplot(gd$pts ~ gd$team, type="db", jit=.2, dist=1.2, col=c(Loss=2,Tie=4,Win=1)[as.character(gd$worl)], las=2, pch=20, cex=.8, panel.first=quote({
- abline(h=median(gd$pts, na.rm=TRUE), lty=3, col=gray(.75))
- abline(h=quantile(gd$pts, .25, na.rm=TRUE), lty=3, col=gray(.75))
- abline(h=quantile(gd$pts, .75, na.rm=TRUE), lty=3, col=gray(.75))
- }), main="Points Scored")
- @
- \subsection*{}
- <<echo=f, fig=t, height=12, width=8>>=
- tplot(gd$opp.pts ~ gd$team, type="db", jit=.2, dist=1.2, col=c(Loss=2,Tie=4,Win=1)[as.character(gd$worl)], las=2, pch=20, cex=.8, panel.first=quote({
- abline(h=median(gd$opp.pts, na.rm=TRUE), lty=3, col=gray(.75))
- abline(h=quantile(gd$opp.pts, .25, na.rm=TRUE), lty=3, col=gray(.75))
- abline(h=quantile(gd$opp.pts, .75, na.rm=TRUE), lty=3, col=gray(.75))
- }), main="Points Against")
- @
- \subsection*{}
- <<echo=f, results=tex>>=
- for (team in colnames(sco)) {
- postscript(paste("graphics/-",team,".eps",sep=""), width=8, height=8, paper="special", horizontal=FALSE)
- rrt2(gd, team)
- dev.off()
- pdf(paste("graphics/-",team,".pdf",sep=""), width=8, height=8, version="1.1", encoding="default")
- rrt2(gd, team)
- dev.off()
- cat("\\includegraphics{graphics/-",team,"}\n", sep="")
- }
- @
- \end{center}
- <<echo=f, fig=f>>=
- save(sco, sch, div, gd, st, wins, loss, file=paste('data.Rdata', sep=''))
- @
- \end{document}
Add Comment
Please, Sign In to add comment