title: Download multiple files using "download.file" function
body: <p>I am trying to download PDFs from a website using R. </p>
  
  <p>I have a vector of the PDF-URLs (<em>pdfurls</em>) and a vector of destination file names (<em>destinations</em>):</p>
  
  <p>e.g.:</p>
  
  <pre><code>pdfurls &lt;- c("http://website/name1.pdf", "http://website/name2.pdf")
  destinations &lt;- c("C:/username/name1.pdf", "C:/username/name2.pdf")
  </code></pre>
  
  <p>The code I am using is:</p>
  
  <pre><code>for(i in 1:length(urls)){
      download.file(urls, destinations, mode="wb")}
  </code></pre>
  
  <p>However, when I run the code, R accesses the URL, downloads the first PDF, and repeats downloading the same PDF over and over again.</p>
  
  <p>I have read this post: <a href="https://stackoverflow.com/questions/16625377/for-loop-on-r-function">for loop on R function</a> and was wondering if this has something to do with the function itself or is there a problem with my loop?</p>
  
  <p>The code is similar to the post here: <a href="https://stackoverflow.com/questions/32241713/how-to-download-multiple-files-using-loop-in-r">How to download multiple files using loop in R?</a> so I was wondering why it is not working and if there is a better way to download multiple files using R. </p>