title: Creating a function to remove only specific word in a list (R)
body: <p>I have a list with undesirable words (in spanish) which are meaningless, but they are also present inside another. I just want to remove it when they are a term, not when they are a piece of another word.</p>
  
  <p>For example: "la" is an spanish article, but if I use a function to remove it, also will break into two words a useful term like "relacion" (which means relationship)</p>
  
  <p>My first choice was creating a function to remove this terms.</p>
  
  <pre><code>bdtidy$tweet &lt;- #here are tweets
  fix.useless &lt;- function(doc) {   
  function(doc) {
  doc &lt;- gsub("la", ".", doc)
  doc &lt;- gsub("las", ".", doc)
  doc &lt;- gsub("el", ".", doc)
  doc &lt;- gsub("ellos", ".", doc)
  doc &lt;- gsub("ellas", ".", doc)
  return(doc)
   }
  
  bdtidy$tweet &lt;- sapply(bdtidy$tweet, fix.useless)
  </code></pre>
  
  <p>My second choice was with a list, and then using filter inside the df</p>
  
  <pre><code>nousar &lt;- c("rt", "pero", "para"...)
  new df %&gt;% bdtidy %&gt;%
   filter(!tweet $in$ nousar))
  </code></pre>
  
  <p>But always the result is removing all those words and breaking terms in two words which makes my analysis useless.
  Thanks.</p>