title: R: Removing Whitespace + Delimiter
body: <p>I'm fairly new to the R language. So I have this vector containing the following:</p>
  
  <pre><code>&gt; head(sampleVector)
  
  [1] "| txt01 |   100 |         200 |       123.456 |           0.12345 |"
  [2] "| txt02 |   300 |         400 |       789.012 |           0.06789 |"
  </code></pre>
  
  <p>I want to extract the lines and break each into separate pieces, with a data value per piece.
  I want to get a list <code>resultList</code>that eventually would print out the following:</p>
  
  <pre><code>&gt; head(resultList)`
  
  [[1]]`  
  [1] ""   "txt01"    "100"       "200"     "123.456"        "0.12345" 
  
  [[2]]`  
  [1] ""   "txt02"    "300"       "400"     "789.012"        "0.06789"
  </code></pre>
  
  <p>I am struggling with the <code>strsplit()</code> notation and I have tried and got the following code so far: </p>
  
  <pre><code>resultList  &lt;- strsplit(sampleVector,"\\s+[|] | [|]\\s+ | [\\s+]")`          
  #would give me the following output`
  
  # [[1]]`    
  # [1] "| txt01"    "100"       "200"     "123.456"        "0.12345 |" 
  </code></pre>
  
  <p>Anyway I can get the output the one <code>strsplit</code> call? I am guessing my notation to distinguish the delimiter + whitespace is wrong. Any help on this would be good.</p>