title: file.path() vs. paste() to create URLs of varying length
body: <p>I'm assembling a few path-to-file URLs.  Many moons ago, I would use <code>paste</code>, but nowadays we have <code>file.path</code> which is supposed to be faster.  The result I am shooting for is</p>
  
  <pre><code>[1] "http://www.retrosheet.org/gamelogs/glfields.txt"   
  [2] "http://www.retrosheet.org/schedule/schedFields.txt"
  [3] "http://www.retrosheet.org/boxfile.txt"  
  </code></pre>
  
  <p>Notice that the third URL doesn't have a "middle" part <code>/.../</code> like the other two. So I try the following with <code>file.path</code> and get an incorrect third element, as expected. </p>
  
  <pre><code>dir &lt;- "http://www.retrosheet.org"
  mid &lt;- c("gamelogs", "schedule", "")
  end &lt;- c("glfields.txt", "schedFields.txt", "boxfile.txt")
  file.path(dir, mid, end)[3]
  # [3] "http://www.retrosheet.org//boxfile.txt"     
  </code></pre>
  
  <p>Changing the third element of <code>mid</code> to <code>NULL</code> just reycles <code>"gamelogs"</code>, which is strange.</p>
  
  <pre><code>mid[3] &lt;- NULL
  file.path(dir, mid, end)[3]
  # [3] "http://www.retrosheet.org/gamelogs/boxfile.txt"  
  </code></pre>
  
  <p>It seems I can get the result this way, but then why not just use <code>paste0(dir, mid, end)</code> without any arguments?</p>
  
  <pre><code>dir &lt;- "http://www.retrosheet.org/"
  mid &lt;- c("gamelogs/", "schedule/", "")
  file.path(dir, mid, end, fsep = "")
  # [1] "http://www.retrosheet.org/gamelogs/glfields.txt"   
  # [2] "http://www.retrosheet.org/schedule/schedFields.txt"
  # [3] "http://www.retrosheet.org/boxfile.txt" 
  </code></pre>
  
  <p><strong>Is there a trick to building these variable-length URLs efficiently using</strong> <code>file.path</code>?</p>