title: Downloading files from ftp with R
body: <p>I am trying to get files from this FTP</p>
  
  <p><a href="ftp://ftp.pride.ebi.ac.uk/pride/data/archive/2015/11/PXD000299/" rel="noreferrer">ftp://ftp.pride.ebi.ac.uk/pride/data/archive/2015/11/PXD000299/</a></p>
  
  <p>From there, I need only the files starting with the .dat extension. But there are other files that I am not interested in.</p>
  
  <p>I want to avoid downloading each one at a time, so I thought in creating a vector with the names and loop over them. </p>
  
  <p>How can I download only the files I want?</p>
  
  <p>Thanks</p>
  
  <p>EDIT:
  I have tried doing the following</p>
  
  <pre><code>downloadURL &lt;- "ftp://ftp.pride.ebi.ac.uk/pride/data/archive/2015/11/PXD000299/F010439.dat"
  download.file(downloadURL, "F010439.dat") #this is a trial using one file
  </code></pre>
  
  <p>And after a few seconds I get the following error:</p>
  
  <pre><code>trying URL 
  
      'ftp://ftp.pride.ebi.ac.uk/pride/data/archive/2015/11/PXD000299/F010439.dat'
      Error in download.file(downloadURL, "F010439.dat") : 
        cannot open URL 'ftp://ftp.pride.ebi.ac.uk/pride/data/archive/2015/11/PXD000299/F010439.dat'
      In addition: Warning message:
      In download.file(downloadURL, "F010439.dat") :
        InternetOpenUrl failed: 'Die FTP-Sitzung wurde beendet.
  
  '
  </code></pre>