# Where can i move this r markdown code?

I hope this is in the correct forum. I am working on a project for a course.

I have this code (please see below) near the top of my .Rmd file and it knitr's just fine.

I need to make the output shorter (course requirement), so i was thinking of putting the code into an init function. Should one do this? Will it work?

I need the code to be run up front. I do want to show the code in the knitr document, but i would like to be in the appendix with the other code,

Any pointers will be appreciated.

Thanks

Edit: looks like everything but the source can go into a function.

{r}
#install.packages('e1071')  # do once in R console.
library(e1071)
source("functions.R")
set.seed(1)
initialize()



Edit2: the code is now smaller:

{r} source("functions.R") initialize() 

{r pressure, include=FALSE}