title: How to remove error in term-document matrix in R?
body: <p>I am trying to create Term-Document matrix using R from a corpus of file. But on running the code I am getting this error followed by 2 warnings:</p>
  
  <pre><code>Error in simple_triplet_matrix(i = i, j = j, v = as.numeric(v), nrow = length(allTerms),  : 
   'i, j' invalid
   Calls: DocumentTermMatrix ... TermDocumentMatrix.VCorpus -&gt;    simple_triplet_matrix -&gt; .Call
  In addition: Warning messages:
  1: In mclapply(unname(content(x)), termFreq, control) :
   scheduled core 1 encountered error in user code, all values of the job will be affected
  2: In simple_triplet_matrix(i = i, j = j, v = as.numeric(v), nrow =   length(allTerms),  :
  NAs introduced by coercion
  </code></pre>
  
  <p>My code is given below:</p>
  
  <pre><code>library(tm)
  library(RWeka)
  library(tmcn.word2vec)
  
  #Reading data
  data &lt;- read.csv("Train.csv", header=T)
  #text &lt;- data$EventDescription
  
  #Pre-processing
  corpus &lt;- Corpus(VectorSource(data$EventDescription))
  corpus &lt;- tm_map(corpus, stripWhitespace)
  corpus &lt;- tm_map(corpus, removePunctuation)
  corpus &lt;- tm_map(corpus, tolower)
  corpus &lt;- tm_map(corpus, PlainTextDocument)
  #dataframe &lt;- data.frame(text=unlist(sapply(corpus,'[',"content")))
  
  #Reading dictionary file
   dict &lt;- scan("dictionary.txt", what='character',sep='\n')
  
  #Bigram Tokenization
  BigramTokenizer &lt;- function(x) NGramTokenizer(x, Weka_control(min = 1, max = 4))
  tdm_doc &lt;- DocumentTermMatrix(corpus,control=list(stopwords = dict,    tokenize=BigramTokenizer))
  tdm_dic &lt;- DocumentTermMatrix(corpus,control=list(tokenize=BigramTokenizer, dictionary=dict))
  </code></pre>
  
  <p>As given in other answers in SO, I have tried installing SnowballC package and other listed ideas. Still I am getting the same error. Can anyone help me in this regard? Thanks in advance.</p>