title: R remove stopwords from a character vector using %in%
body: <p>I have a data frame with strings that I'd like to remove stop words from.  I'm trying to avoid using the <code>tm</code> package as it's a large data set and <code>tm</code> seems to run a bit slowly.  I am using the <code>tm</code> <code>stopword</code> dictionary.</p>
  
  <pre><code>library(plyr)
  library(tm)
  
  stopWords &lt;- stopwords("en")
  class(stopWords)
  
  df1 &lt;- data.frame(id = seq(1,5,1), string1 = NA)
  head(df1)
  df1$string1[1] &lt;- "This string is a string."
  df1$string1[2] &lt;- "This string is a slightly longer string."
  df1$string1[3] &lt;- "This string is an even longer string."
  df1$string1[4] &lt;- "This string is a slightly shorter string."
  df1$string1[5] &lt;- "This string is the longest string of all the other strings."
  
  head(df1)
  df1$string1 &lt;- tolower(df1$string1)
  str1 &lt;-  strsplit(df1$string1[5], " ")
  
  &gt; !(str1 %in% stopWords)
  [1] TRUE
  </code></pre>
  
  <p>This is not the answer I'm looking for.  I'm trying to get a vector or string of the words NOT in the <code>stopWords</code> vector. </p>
  
  <p>What am I doing wrong?</p>