title: how to add a (multipage) pdf to rmarkdown?
body: <p>Consider this simple example</p>
  
  <pre><code>library(dplyr)
  library(ggplot2)
  library(tidyr)
  
  mydata &lt;- data_frame(group = c('a', 'a', 'a', 'b', 'b', 'b'),
                       x = c(1,2,3,5,6,7),
                       y = c(3,5,6,4,3,2))
  
  mydata2 &lt;- mydata %&gt;% group_by(group) %&gt;% 
    nest() %&gt;% 
    mutate(myplot = map(data, ~ggplot(data = .x, aes(x = x, y = x)) + geom_point()))
  
  pdf("P://mychart.pdf")
  print(mydata2$myplot)
  dev.off()
  </code></pre>
  
  <p>The code above will output a pdf with two pages. How can I show these two pages on my <code>rmarkdown</code> document?</p>
  
  <p>Using</p>
  
  <pre><code>---
  title: "crazy test"
  output:
    pdf_document
  ---
  
  ```{r global_options, include=FALSE}
  knitr::opts_chunk$set(echo = TRUE, fig.pos = 'h')
  ```
  
  
  ttt
  
  ## this is a test!!
  
  ```{r label, out.width = "85%", fig.cap = "caption"}
  knitr::include_graphics(path = "P://mychart.pdf")
  ```
  </code></pre>
  
  <p>will only show the first page of the <code>pdf</code>! Where is the other chart? :(</p>
  
  <p><a href="https://i.stack.imgur.com/hDd6d.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hDd6d.png" alt="enter image description here"></a></p>
  
  <p>Any ideas?</p>
  
  <p>Thanks!</p>