title: r split a column into multiple columns
body: <p>I'm trying to split a column of strings in a dataframe into multiple columns based a delimiting pattern, i.e., a column of strings "a b" and "c  d" should be split into two columns, one with "a" and "c", and another with "b" and "d". The delimiting pattern is in my case any sequence of characters that does not contain <code>a-zA-Z0-9@.</code></p>
  
  <p>As suggested <a href="https://stackoverflow.com/questions/4350440/split-a-column-of-a-data-frame-to-multiple-columns">here</a> I'm trying to use <code>stringr</code>. However, it seems that <code>str_split</code> is sensitive to the number of spaces?</p>
  
  <pre><code>&gt; xxx&lt;-str_split_fixed(c("a b", "c  d")," ",3)
  &gt; xxx
        [,1] [,2] [,3]
   [1,] "a"  "b"  ""  
   [2,] "c"  ""   "d" 
  
  &gt; xxx&lt;-str_split_fixed(c("a b", "c  d"),"[:space:] ",3)
  &gt; xxx
        [,1] [,2] [,3]
   [1,] ""   "b"  ""  
   [2,] ""   " d" ""  
  
  &gt; xxx&lt;-str_split_fixed(c("a b", "c  d"),"' '+",3)
  &gt; xxx
        [,1]   [,2] [,3]
   [1,] "a b"  ""   ""  
   [2,] "c  d" ""   ""  
  </code></pre>