title: R Extract duplicate words in string
body: <p>I have strings <code>a</code> and <code>b</code> that compose my <code>data</code>. My purpose is to obtain a new variable that contains repeated words.</p>
  
  <pre><code>    a = c("the red house av", "the blue sky", "the green grass")
      b = c("the house built", " the sky of the city", "the grass in the garden")
  
  data = data.frame(a, b)
  </code></pre>
  
  <p>Based on this <a href="https://stackoverflow.com/questions/28033312/r-how-do-keep-only-unique-words-within-each-string-in-a-vector">answer</a> I can get the logical of those that are repeated with <code>duplicated()</code></p>
  
  <pre><code>data = data%&gt;% mutate(c = paste(a,b, sep = " "),
                       d = vapply(lapply(strsplit(c, " "), duplicated), paste, character(1L), collapse = " "))
  </code></pre>
  
  <p>Yet I am not able to obtain the words. My desired data should be something like this </p>
  
  <pre><code>&gt; data.1
                   a                       b         d
  1 the red house av         the house built the house
  2     the blue sky     the sky of the city   the sky
  3  the green grass the grass in the garden the grass
  </code></pre>
  
  <p>Any help on the function above would be highly appreciated. </p>