首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从RTextTools使用create_matrix会在simple_triplet_matrix中产生错误(i= i,j=j

从RTextTools使用create_matrix会在simple_triplet_matrix中产生错误(i= i,j=j
EN

Stack Overflow用户
提问于 2017-02-18 02:10:34
回答 1查看 339关注 0票数 0

以前有人问过这个问题,但是在一个旧的线程中,从来没有被解决过。人们在这个帖子的底部遇到了这个-- Finding 2 & 3 word Phrases Using R TM Package,R基础代码和包都是新安装的。我无法得到任何二元模型或三元模型的解决方案-它们都产生了相同的错误,但我认为我可以从这里开始。我将给出一个带有输出和版本的简单示例。

代码语言:javascript
复制
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        
EN

回答 1

Stack Overflow用户

发布于 2017-03-03 01:51:11

我通过从R版本3.3.2恢复到3.2.2解决了类似的问题

我的情况略有不同,因为我使用的是tm包中的DocumentTermMatrix,并收到一个错误:

代码语言:javascript
复制
Error in simple_triplet_matrix(i = i, j = j, v = as.numeric(v), nrow = length(allTerms),  : 
  'i, j'  invalid

当我运行R版本3.2.2时,不会出现此错误。在升级到3.3.2版本时,相同的代码段会发生此错误。也许降级会奏效。很抱歉,我不能提供一个实际的答案,为什么会发生这个错误...

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42304753

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档