1

I'm using R 3.3.0 and for some reason, I cannot create a DTM without receiving the error:

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
The weird thing is, this error occurred only recently. I tried it before and it worked fine.

below I pasted the code I used:

#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)

the last 2 lines I added later on after reading other posts on stackoverflow on this error. However, it still does not work.

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   

I need to run this for my master thesis. I am a beginner in R and I really hope someone can help me!

Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
Amarins
  • 43
  • 1
  • 1
  • 5
  • What exactly doesn't work? Which line causes the error you posted? Are you sure `corpus` is defined correctly? – Gregor Thomas Oct 28 '16 at 17:28
  • when I run this bit:myDtm <- DocumentTermMatrix( my_corpus, control=list( wordLengths=c(3,Inf) ) ) – Amarins Oct 28 '16 at 17:40
  • Works fine with `corpus <- Corpus(VectorSource(c("hello world")))` and `slam_0.1-32` on R version 3.3.1 (2016-06-21); Platform: x86_64-w64-mingw32/x64 (64-bit). Please always provide a minimal reproducible example. This includes a minimal dataset and the necessary library calls - see [how to provide minimal reproducible examples in R](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#answer-5963610). – lukeA Oct 28 '16 at 20:19
  • yes but for some reason when you use a bigger data set it does not work anymore. – Amarins Oct 29 '16 at 10:31
  • Difficult to debug if there's no other hint then "bigger data set". – lukeA Oct 30 '16 at 23:59

0 Answers0