title: Copying data from text into new columns in R
body: <p>I have compiled a dataset of tweets using the Twitter API.</p>
  
  <p>The dataset basically looks as follows:</p>
  
  <pre><code>Data &lt;- data.frame(
    X = c(1,2),
    text = c("Hello @User1 #hashtag1, hello @User2 and @User3, #hashtag2", "Hello @User2 #hashtag3, hello @User1 and @User3, #hashtag4"),
    screenname = c("author1", "author2")
  ) 
  </code></pre>
  
  <p>Now I want to create a <code>data.frame</code> for social network analysis. I want to show how each of the screennames (in the case of this example "author1" etc.) is linked to users ("@User1" etc.) and hashtags ("#hashtag1", etc.).</p>
  
  <p>To so, I need to extract/copy users and hashtags from the "text" column and write them in new columns. The <code>data.frame</code>should look like this:</p>
  
  <pre><code>Data &lt;- data.frame(
    X = c(1,2),
    text = c("Hello @User1 #hashtag1, hello @User2 and @User3, #hashtag2", "Hello @User2 #hashtag3, hello @User1 and @User3, #hashtag4"),
    screenname = c("author1", "author2"),
    U1 = c("@User1", "@User2"),
    U2 = c("@User2", "@User1"),
    U3 = c("@User3", "@User3"),
    U4 = c("",""),
    U5 = c("",""),
    H1 = c("#hashtag1", "#hashtag3"),
    H2 = c("#hashtag2", "#hashtag4"),
    H3 = c("",""),
    H4 = c("",""),
    H5 = c("","")
  )
  </code></pre>
  
  <p>How can I extract/copy this information from the "text" column and write it into new columns?</p>