replace hardcoded code with knitr code chunks