title: Extract vector from list in R
body: <p>I have been trying to do this for a while but could not reach a solution...</p>
  
  <p>I have one list, say a: </p>
  
  <pre><code>&gt; a
  [[1]]
  [1] 10 30
  
  [[2]]
  [1] 15 20
  
  [[3]]
  [1] 12 15 30
  
  $[[4]]
  [1] 15 30 20
  </code></pre>
  
  <p>I would like to extract the first element, the second and the third to vectors.</p>
  
  <p>I know how to extract the first and second elements:</p>
  
  <pre><code>first &lt;- sapply(a, "[[", 1)
  second &lt;- sapply(a, "[[", 2)
  </code></pre>
  
  <p>But when trying to extract the third, I get an error, because there is no third element in some vectors from the list.</p>
  
  <p>How could I do this? Should I add a zero to the vectors in the list having  only two values?</p>