title: How to complete a stemmed corpus from a dictionary using stemCompletion function (tm package)
body: <p>I am having a trouble in the tm package of R. I am using 0.6.2 version. Following question (2 different errors) has already been answered <a href="https://stackoverflow.com/questions/24191728/documenttermmatrix-error-on-corpus-argument">here</a> and <a href="https://stackoverflow.com/questions/24771165/r-project-no-applicable-method-for-meta-applied-to-an-object-of-class-charact">here</a> but still producing an error after using the posted solution. Please click <a href="https://drive.google.com/file/d/0B2YVITpwU9nPTjdDLUV4YXJFSlU/view?usp=sharing" rel="nofollow noreferrer">here</a> to download the dataset (93 rows only). It's a reproducible example.
  the two errors are below:</p>
  
  <ol>
  <li><p><strong>(Resolved)</strong> Error in UseMethod("meta", x) : 
  no applicable method for 'meta' applied to an object of class "character"</p></li>
  <li><p>Error: inherits(doc, "TextDocument") is not TRUE</p></li>
  <li>tm_map(ds.corpus, PlainTextDocument) does not create a plain text document in this case. 
  inherits(ds.cleanCorpus, "TextDocument") # returns FALSE</li>
  </ol>
  
  <p>please tell me what is wrong in my approach.</p>
  
  <p>--</p>
  
  <pre><code>  # Data import
      df.imp&lt;- read.csv("Phone2_Sample100_NegPos.csv", header = TRUE, as.is = TRUE)
  
     ##### Data Pre-Processing 
  
          install.packages("tm")
      require(tm)  
  
      ds.corpus&lt;- Corpus(VectorSource(df.imp$Content))
  
      ds.corpus&lt;- tm_map(ds.corpus, content_transformer(tolower))
      ds.corpus&lt;- tm_map(ds.corpus, content_transformer(removePunctuation))
      ds.corpus&lt;- tm_map(ds.corpus, content_transformer(removeNumbers))
      removeURL&lt;- function(x) gsub("http[[:alnum:]]*", "", x)
      ds.corpus&lt;- tm_map(ds.corpus,removeURL)
  
      stopwords.default&lt;- stopwords("english")
      stopWordsNotDeleted&lt;- c("isn't" ,     "aren't" ,    "wasn't" ,    "weren't"   , "hasn't"    ,
                              "haven't" ,   "hadn't"  ,   "doesn't" ,   "don't"      ,"didn't"    ,
                              "won't"   ,   "wouldn't",   "shan't"  ,   "shouldn't",  "can't"     ,
                              "cannot"    , "couldn't"  , "mustn't", "but","no", "nor", "not", "too", "very")
  
      stopWord.new&lt;- stopwords.default[! stopwords.default %in% stopWordsNotDeleted] ## new Stopwords list
      ds.corpus&lt;- tm_map(ds.corpus, removeWords, stopWord.new )
  
      copy&lt;- ds.corpus ## creating a copy to be used as a dictionary
  
      ds.corpus&lt;- tm_map(ds.corpus, stemDocument)
  
      ## error Statement #1
      ds.corpus&lt;-  stemCompletion(ds.corpus, dictionary = copy) 
      ## Error in UseMethod("meta", x) : no applicable method for 'meta' applied to an object of class "character"
  
  
  
  
      ds.cleanCorpus&lt;- tm_map(ds.corpus, PlainTextDocument) ## creating plain text document
  
      class(ds.cleanCorpus) ## output is VCorpus" "Corpus".  what it should be??
  
      ## error Statement #2
      tdm&lt;- TermDocumentMatrix(ds.corpus) ## creating  term document matrix 
  
      inherits(ds.cleanCorpus, "TextDocument") ## returns FALSE
  </code></pre>
  
  <p><strong>Update:</strong> 
  Figured out first error, that the stemCompletion method's x parameter should be a character vector and dictionary could be either a corpus or character vector. However, when I tried it on first document (character vector) of ds.corpus, as below, stemmed words were not completed and output is just the stemmed character vector like before.</p>
  
  <pre><code>stemCompletion(ds.corpus[[1]]$content, dictionary = copy) 
  </code></pre>
  
  <p>So now my main question is "<strong>How to complete a stemmed corpus from a dictionary (tm package)?</strong>" The stemCompletion method doesn't seems working (on a character vector). Secondly, how can I complete the stemming of an entire corpus, should I use a for loop for each document of the corpus's content?</p>