title: Convert .png to multi-page pdf using Magick in R
body: <p>I have a directory full of 100 .png images I'd like to convert to pdf.</p>
  
  <p>The images are exactly the size I want the pdf to be.</p>
  
  <p>I can create a multi-page pdf using <code>magick</code> "manually" like this:</p>
  
  <pre><code>library(magick)
  
  img1 &lt;- image_read("image1.png")
  img2 &lt;- image_read("image2.png")
  
  image_write(c(img1, img2), format = "pdf", "check.pdf")
  </code></pre>
  
  <p>But I'm having trouble getting the image_write command to accept a vector of filenames to automate this process. For example, I'd like to make a 100-page pdf from the .png images in my directory "test":</p>
  
  <pre><code>all_images &lt;- list.files("test")
  </code></pre>
  
  <p>I thought that <code>purrr</code> might help but no luck:</p>
  
  <pre><code>library(purrr)
  
  image_write(map(all_images, image_read), format = "pdf", "check.pdf")
  </code></pre>
  
  <p>Any ideas?</p>