title: R stemming a string/document/corpus
body: <p>I'm trying to do some stemming in R but it only seems to work on individual documents.  My end goal is a term document matrix that shows the frequency of each term in the document.</p>
  
  <p>Here's an example:</p>
  
  <pre><code>require(RWeka)
  require(tm)
  require(Snowball)
  
  worder1&lt;- c("I am taking","these are the samples",
  "He speaks differently","This is distilled","It was placed")
  df1 &lt;- data.frame(id=1:5, words=worder1)
  
  &gt; df1
    id                 words
  1  1           I am taking
  2  2 these are the samples
  3  3 He speaks differently
  4  4     This is distilled
  5  5         It was placed
  </code></pre>
  
  <p>This method works for the stemming part but not the term document matrix part:</p>
  
  <pre><code>&gt; corp1 &lt;- Corpus(VectorSource(df1$words))
  &gt; inspect(corp1)
  A corpus with 5 text documents
  
  The metadata consists of 2 tag-value pairs and a data frame
  Available tags are:
    create_date creator 
  Available variables in the data frame are:
    MetaID 
  
  [[1]]
  I am taking
  
  [[2]]
  these are the samples
  
  [[3]]
  He speaks differently
  
  [[4]]
  This is distilled
  
  [[5]]
  It was placed
  
  &gt; corp1 &lt;- tm_map(corp1, SnowballStemmer)
  &gt; inspect(corp1)
  A corpus with 5 text documents
  
  The metadata consists of 2 tag-value pairs and a data frame
  Available tags are:
    create_date creator 
  Available variables in the data frame are:
    MetaID 
  
  [[1]]
  [1] I am tak
  
  [[2]]
  [1] these are the sampl
  
  [[3]]
  [1] He speaks differ
  
  [[4]]
  [1] This is distil
  
  [[5]]
  [1] It was plac
  
  &gt;  class(corp1)
  [1] "VCorpus" "Corpus"  "list"   
  &gt; tdm1 &lt;- TermDocumentMatrix(corp1)
  Error in UseMethod("Content", x) : 
    no applicable method for 'Content' applied to an object of class "character"
  </code></pre>
  
  <p>So instead I tried creating the term document matrix first but this time the words don't get stemmed:</p>
  
  <pre><code>&gt; corp1 &lt;- Corpus(VectorSource(df1$words))
  &gt; tdm1 &lt;- TermDocumentMatrix(corp1, control=list(stemDocument=TRUE))
  &gt;  as.matrix(tdm1)
               Docs
  Terms         1 2 3 4 5
    are         0 1 0 0 0
    differently 0 0 1 0 0
    distilled   0 0 0 1 0
    placed      0 0 0 0 1
    samples     0 1 0 0 0
    speaks      0 0 1 0 0
    taking      1 0 0 0 0
    the         0 1 0 0 0
    these       0 1 0 0 0
    this        0 0 0 1 0
    was         0 0 0 0 1
  </code></pre>
  
  <p>Here the words are obviously not stemmed.</p>
  
  <p>Any suggestions?</p>