title: Create a list where each element is a pair of contiguous members from given vector
body: <p>Or how to split a vector into pairs of contiguous members and combine them in a list?</p>
  
  <p>Supose you are given the vector</p>
  
  <pre><code>map &lt;-seq(from = 1, to = 20, by = 4)
  </code></pre>
  
  <p>which is</p>
  
  <pre><code>1  5  9  13  17
  </code></pre>
  
  <p>My goal is to create the following list</p>
  
  <pre><code>path &lt;- list(c(1,5), c(5,9), c(9,13), c(13,17))
  </code></pre>
  
  <p>This is supposed to represent the several path segments that the map is sugesting us to follow. In order to go from 1 to 17, we must first take the first path (<code>path[1]</code>), then the second path (<code>path[2]</code>), and all the way to the end.</p>
  
  <p>My first attempt lead me to:</p>
  
  <pre><code>path &lt;- split(aux &lt;- data.frame(S = map[-length(map)], E = map[-1]), row(aux))
  </code></pre>
  
  <p>But I think it would be possible without creating this auxiliar data frame
  and avoiding the performance decrease when the initial vector (the <code>map</code>) is to big. Also, it returns a warning message which is quite alright, but I like to avoid them.</p>
  
  <p>Then I found this here on stackoverflow (not exactly like this, this is the adapted version for my problem):</p>
  
  <pre><code>mod_map &lt;- c(map, map[c(-1,-length(map))])
  mod_map &lt;- sort(mod_map)
  split(mod_map, ceiling(seq_along(mod_map)/2))
  </code></pre>
  
  <p>which is a simpler solution, but I have to use this modified version of my <code>map</code>.</p>
  
  <p>Pherhaps I'm asking too much as I already got two solutions. But, could it be possible to have a third one, so that I don't have so use data frames as in my first solution and can use the original map, unlike my second solution?</p>