title: Rmarkdown: Explicitly specify the figure size of a plot within a chunk
body: <p>I'm using RMarkdown to functionally create a document using <code>results = 'asis'</code> with a <code>purrr::map</code>.  There are multiple plots that come out of the chunk on each <code>purrr</code> iteration.  Most of them are the same size, and can be set using the chunk options for figure size.  However one or two need to have a different size.  It is not possible to separate the code into different chunks due to the way the loop/map is set up.</p>
  
  <p>The closest I've found is <a href="http://michaeljw.com/blog/post/subchunkify/" rel="nofollow noreferrer">http://michaeljw.com/blog/post/subchunkify/</a>, however when I use this on the plot that needs different sizing, it causes the first iteration's plots that were output using the print() function to be recycled in the subchunkify's plots location.  </p>
  
  <p>Is there a different, less hacky way to do this?  Or is there something obvious in the subchunkify code that would be fixable?</p>
  
  <p>Here is <code>subchunkify()</code>:</p>
  
  <pre><code>subchunkify &lt;- function(g, fig_height=7, fig_width=5) {
    g_deparsed &lt;- paste0(deparse(
      function() {g}
    ), collapse = '')
  
    sub_chunk &lt;- paste0("
    `","``{r sub_chunk_", floor(runif(1) * 10000), ", fig.height=", fig_height, ", fig.width=", fig_width, ", echo=FALSE}",
    "\n(", 
      g_deparsed
      , ")()",
    "\n`","``
    ")
  
    cat(knitr::knit(text = knitr::knit_expand(text = sub_chunk), quiet = TRUE))
  }
  </code></pre>