title: Concatenate previous and latter words to a word that match a condition in R
body: <p>I need to concatenate the previous and the latter words of a condition meeting word. Specifically, those who match the condition of having a comma. </p>
  
  <pre><code>vector &lt;- c("Paulsen", "Kehr,", "Diego",    "Schalper", "Sepúlveda,", "Diego")
  
  #I know how to get which elements meet my condition:
  
  grepl(",", vector)
  #[1] FALSE  TRUE FALSE FALSE  TRUE FALSE 
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>print(vector_ok)
  #[1] "Paulsen Kehr, Diego", "Schalper Sepúlveda, Diego"
  </code></pre>
  
  <p>Thanks in advance!</p>