Cleaned up the knitr compilation problems and moved the plotting code inside of the solution.