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:
- Added content_transformation(toolbar)
- Added lazy=TRUE at the end of the code in every executable line
- Removed the code: myCorpus <- tm_map(myCorpus, stemDocument)
- Added mc.cores = 1 after (tolower)
- Added mc.cores = 1 in every line of the code
- Changed the last code to myTdm <- TermDocumentMatrix(Corpus(VectorSource(myCorpus)))
- 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?