0

I have the following data:

text <- c("@_rpg_17 little league travel tourney. These parents about to be wild.", 
"@auscricketfan @davidwarner31 yes WI tour is coming soon", "@keralatourism #favourite #destination #munnar #topstation https://t.co/sm9qz7Z9aR", 
"@NWAWhatsup tour of duty in NWA considered a dismal assignment?  Companies send in their best ppl and then those ppl don't want to leave", 
"Are you Looking for a trip to Kerala? #Kerala-prime tourist attractions of India.Visit:http://t.co/zFCoaoqCMP http://t.co/zaGNd0aOBy", 
"Are you Looking for a trip to Kerala? #Kerala, God's own country, is one of the prime tourist attractions of... http://t.co/FLZrEo7NpO")

The following is the code:

library(tm)
myCorpus <- Corpus(VectorSource(text))
myCorpus <- tm_map(myCorpus, tolower)
myCorpus <- tm_map(myCorpus, removePunctuation)
myCorpus <- tm_map(myCorpus, removeNumbers)
removeURL <- function(x) gsub("http[[:alnum:]]*", "", x)
myCorpus <- tm_map(myCorpus, removeURL)
myStopwords <- c(stopwords('english'), "available", "via")
myCorpus <- tm_map(myCorpus, removeWords, myStopwords)
myCorpusCopy <- myCorpus
myCorpus <- tm_map(myCorpus, stemDocument)
myTdm <- TermDocumentMatrix(myCorpus, control=list(wordLengths=c(3,Inf)))

This used to work perfectly earlier in my windows machine. Not sure if this could be because of the mac which I use currently. I get the error given above in the subject line. On other occasions I get other error:

Error in UseMethod("meta", x) : no applicable method for 'meta' applied to an object of class "character"
In addition: Warning message:In mclapply(unname(content(x)), termFreq, control) :all scheduled cores encountered errors in user code

I use R version 3.2.0 (2015-04-16) -- "Full of Ingredients", R-Studio Version 0.98.1103, Mac OS X Yosemite 10.10.3, library(tm) version 0.6 - 1. I have tried the following changes in the code:

  1. Added content_transformation(toolbar)
  2. Added lazy=TRUE at the end of the code in every executable line
  3. Removed the code: myCorpus <- tm_map(myCorpus, stemDocument)
  4. Added mc.cores = 1 after (tolower)
  5. Added mc.cores = 1 in every line of the code
  6. Changed the last code to myTdm <- TermDocumentMatrix(Corpus(VectorSource(myCorpus)))
  7. Immediately after myCorpus <- tm_map(myCorpus, tolower) used myCorpus <- tm_map(myCorpus, PlainTextDocument), tried this with content_transformation too.

and other solutions given in stack overflow. Nothing seem to work. Don't know how to resolve?

Apricot
  • 2,925
  • 5
  • 42
  • 88
  • Saying "that is the data" is not helpful since you are passing a list to your function named `test` which is supposed to also have an item named `test` and we cannot tell whether you just don't understand that what you offer is just an atomic character vector or whether the confusion is something more complicated. – IRTFM Jul 21 '15 at 18:57
  • 1
    You need to wrap your `removeURL` in a `content_transformer()` as well (just like with `tolower`). – MrFlick Jul 21 '15 at 19:08
  • Many thanks MrFlick. This helped. – Apricot Jul 21 '15 at 19:13

0 Answers0