title: How to include a header based on a condition in knitr
body: <p>I have a header followed by a code chunk in an Rmd file. I only want to include this header and the chunk followed by it, if a condition is met. I know how to do that with the chunk, since it's in the body of the code, but how do I do the former? </p>
  
  <pre><code>```{r}
   print_option &lt;- TRUE
  ```
  
  ## My header
  ```{r}
   if(print_option==TRUE) {
   print (x)
   }
  ```
  </code></pre>