title: Inserting a page break within a code chunk in rmarkdown (converting to pdf)
body: <p>I am using rmarkdown, pandoc and knitr to create a pdf including chunks of r code. Within a code chunk I have a for loop which prints a number of graphs and some statistical output. </p>
  
  <p>I would like to insert a page break into the loop (to appear in the pdf output). This page break would occur after each graph is printed, to ensure each graph is printed on one page and the statistical output on the next. </p>
  
  <p>I have been unable to find a way of including a page break in my r code chunk. I have tried <code>cat("\\newpage")</code> and <code>cat("\\pagebreak")</code> in the hopes it would be recognized by pandoc but to no avail (it is just printed verbatim in the final pdf). </p>
  
  <p>Suggestions appreciated.  Here is the code I have so far:</p>
  
  <pre><code>```{r, echo =FALSE, message=FALSE, warning=FALSE, comment=NA, results='asis'}
  library("markdown") 
  library("rmarkdown") 
  library("knitr")
  library("ggplot2")
  for (v in Values){
  
  # read in file
  testR &lt;- read.csv(file.path, header=T)
  
  print(ggplot(testR, aes(x=Time, y=Value, color=Batch)) + geom_point(size = 3) +
  xlab ("Timepoint") +
  ylab (v) +
  scale_x_continuous(breaks=seq(0, 60, by=6)) +
  ggtitle(paste("Scatterplot of Batches for ", v, sep="")))
  ggsave(paste(timestamp, "__", 
         "Scatterplot of Batches for ", v, ".jpeg", sep = "")) 
  
  cat("\\pagebreak")
  writeLines(v)
  writeLines("\n")
  writeLines("\n Test for homogenity of slopes \n")
  av1 &lt;- aov(Value~Time*Batch, data=testR)
  print(summary(av1))
  }
  ```
  </code></pre>