我正在使用 Rstudio 3.3.0,由于某种原因,我似乎无法使用以下代码创建 DTM 而不会收到错误:
Error in UseMethod("meta", x) :
no applicable method for 'meta' applied to an object of class "try-error"
In addition: Warning messages:
1: In mclapply(x$content[i], function(d) tm_reduce(d, x$lazy$maps)) :
all scheduled cores encountered errors in user code
2: In mclapply(unname(content(x)), termFreq, control) :
all scheduled cores encountered errors in user code
奇怪的是,这个错误最近才发生。我以前试过,效果很好。
我使用的代码如下
#pre-processing and transforming the corpus
myStopwords<- c(stopwords("english"), stopwords("SMART"))
my_corpus <- tm_map(corpus, content_transformer(tolower),lazy=TRUE)
my_corpus <- tm_map(my_corpus, removeWords, myStopwords, lazy=TRUE)
my_corpus <- tm_map(my_corpus, removeNumbers, lazy=TRUE)
my_corpus <- tm_map(my_corpus, removePunctuation, lazy=TRUE)
my_corpus <- tm_map(my_corpus, stripWhitespace, lazy=TRUE)
my_corpus <- tm_map(my_corpus, stemDocument, lazy=TRUE)
my_corpus <- tm_map(my_corpus, PlainTextDocument, lazy=TRUE)
my_corpus <- tm_map(my_corpus, content_transformer(function(x) iconv(x, to='UTF-8-MAC', sub='byte')), mc.cores=1, lazy=TRUE)
在阅读有关此错误的 stackoverflow 上的其他帖子后,我稍后添加了最后 2 行。但是,它仍然不起作用。
myDtm <- DocumentTermMatrix(
my_corpus, control=list(
wordLengths=c(3,Inf)
)
)
sessioninfo() 的以下结果
R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] wordcloud_2.5 RColorBrewer_1.1-2 slam_0.1-35
[4] SnowballC_0.5.1 tm_0.6-2 NLP_0.1-9
loaded via a namespace (and not attached):
[1] parallel_3.3.0 tools_3.3.0 Rcpp_0.12.5
我已经尝试了一整天来解决这个问题,但我无法自己解决。我想我错过了什么。
请任何人帮助我!