0

This has been asked before but in an old thread and was never addressed. People ran into this at the bottom of this thread - Finding 2 & 3 word Phrases Using R TM Package The R base code and packages are fresh installs. I could not get any bigram or trigram solution to work - they all yielded the same error, but I thought I'd start here. I will give a simple example with output and versions.

library("RTextTools")
library(tm)
texts <- c("This is the first document.", "This is the second file.", "This is the third text.")
corpus <- Corpus(VectorSource(texts))
matrix <- create_matrix(texts,ngramLength=3)   

Error in simple_triplet_matrix(i = i, j = j, v = as.numeric(v), nrow = length(allTerms),  : 
  'i, j, v' different lengths
In addition: Warning messages:
1: In mclapply(unname(content(x)), termFreq, control) :
  all scheduled cores encountered errors in user code
2: In simple_triplet_matrix(i = i, j = j, v = as.numeric(v), nrow = length(allTerms),  :
  NAs introduced by coercion

print(sessionInfo())
version
               _                           
platform       x86_64-apple-darwin13.4.0   
arch           x86_64                      
os             darwin13.4.0                
system         x86_64, darwin13.4.0        
status                                     
major          3                           
minor          3.2                         
year           2016                        
month          10                          
day            31                          
svn rev        71607                       
language       R                           
version.string R version 3.3.2 (2016-10-31)
nickname       Sincere Pumpkin Patch       
print(sessionInfo())
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.3

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RTextTools_1.4.2 SparseM_1.74     tm_0.6-2         NLP_0.1-9        Matrix_1.2-7.1  

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.9         splines_3.3.2       MASS_7.3-45         tau_0.0-18          prodlim_1.5.9      
 [6] lattice_0.20-34     foreach_1.4.3       caTools_1.17.1      tools_3.3.2         nnet_7.3-12        
[11] parallel_3.3.2      grid_3.3.2          ipred_0.9-5         glmnet_2.0-5        e1071_1.6-8        
[16] iterators_1.0.8     class_7.3-14        survival_2.39-5     randomForest_4.6-12 lava_1.4.7         
[21] bitops_1.0-6        codetools_0.2-15    maxent_1.3.3.1      rpart_4.1-10        slam_0.1-40        
[26] tree_1.0-37        
Community
  • 1
  • 1
Doug C
  • 33
  • 1
  • 5

1 Answers1

0

I solved a similar problem by reverting from R version 3.3.2 to 3.2.2
My situation was slightly different in that I was using the DocumentTermMatrix in the tm package and receiving an error:

Error in simple_triplet_matrix(i = i, j = j, v = as.numeric(v), nrow = length(allTerms),  : 
  'i, j'  invalid

This error did not occur when I was running R version 3.2.2. Upon upgrading to 3.3.2 this error occurred on the identical piece of code. Perhaps downgrading will work. I'm sorry I cannot provide an actual answer as to why this error is occurring...

Julien
  • 1,946
  • 3
  • 33
  • 51