1

I'm using Rstudio 3.3.0 and for some reason I can't seem to create a DTM using the following code 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.

The code I use is the following

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

The following results from the 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 have tried the entire day to fix this problem but can't work it out on my own. I mussed be missing something.

please anyone help me!

Amarins
  • 43
  • 1
  • 1
  • 5
  • Anyone? I am a beginner and I need this for my master thesis. I am super stuck. any help would be very nice! – Amarins Oct 28 '16 at 16:04

1 Answers1

1

Try wrapping all of your second arguments to tm_map in content_transformer().

For example:

my_corpus <- tm_map(my_corpus, content_transformer(removeWords), 
                     myStopwords, lazy=TRUE)

I'm not positive it will fix your issue, but I thought I'd at least try.

Kairsten
  • 91
  • 7