title: Output Rmarkdown from R notebook
body: <p>I would like to output Rmarkdown from my notebook when I knit it from Rstudio (see below for the reason). I can <em>almost</em> get what I want, for example:</p>
  
  <pre><code>---
  title: "Homework"
  output:
    html_document:
      keep_md: true
      md_extensions: +backtick_code_blocks
  ---
  
  ```{r setup, include=FALSE}
  knitr::opts_chunk$set(eval = FALSE, echo = TRUE)
  ```
  
  Fill the function:
  
  ```{r echo=-3}
  is_even = function(n) {
    # TODO
    n %% 2 == 0
  }
  
  if(is_even(8)) {
    print("correct!")
  } else {
    print("wrong!")
  }
  ```
  </code></pre>
  
  <p>The resulting markdown file is <em>almost</em> correct:</p>
  
  <pre><code>Fill the function:
  
  ```r
  is_even = function(n) {
    # TODO
  }
  
  if(is_even(8)) {
    print("correct!")
  } else {
    print("wrong!")
  }
  ```
  </code></pre>
  
  <p>I just need a way to replace the code block preamble from <code>r</code> to <code>{r}</code>. I could just run <code>sed</code>, but I would like to have everything done when knitting from within RStudio, if possible.</p>
  
  <p>Use case: coding assignments. Write a single file with both questions and answers, and strip answers away when knitting, so that I can give the resulting markdown (without answers) to students. They can then open it in Rstudio and fill in what is needed.</p>