When I run the following codes to the penultimate line, I got Warning message:
In mclapply(content(x), FUN, ...) : all scheduled cores encountered errors in user code
When I run the final line, I got
"Error in UseMethod(\"words\") : \n no applicable method for 'words' applied to an object of class \"character\"\n" attr(,"class") "try-error" attr(,"condition")
The following link is a reproducible example which we can copy/paste into R and run.
https://github.com/weijia2013/mclapply-issue/blob/master/codes
I just start learn R and I'll be appreciate your help.
library(devtools)
install_github("twitteR", username="geoffjentry")
library(twitteR)
setup_twitter_oauth("API Key", "API Secret")
rdmTweets <- userTimeline('rdatamining', n=200)
(nDocs <- length(rdmTweets))
rdmTweets[11:15]
for (i in 11:15) {cat(paste("[[", i, "]] ", sep="")) + writeLines(strwrap(rdmTweets[[i]]$getText(), width=73))}
df <- do.call("rbind", lapply(rdmTweets, as.data.frame))
dim(df)
library(tm)
library(SnowballC)
library(RWeka)
library(rJava)
library(RWekajars)
myCorpus <- Corpus(VectorSource(df$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")
myStopwords <- setdiff(myStopwords, c("r", "big"))
myCorpus <- tm_map(myCorpus, removeWords, myStopwords)
myCorpusCopy <- myCorpus
myCorpus <- tm_map(myCorpus, stemDocument)
for (i in 11:15) {cat(paste("[[", i, "]] ", sep="")) + writeLines(strwrap(myCorpus[[i]], width=73))}
myCorpus <- tm_map(myCorpus, stemCompletion, dictionary=myCorpusCopy)
inspect(myCorpus[11:15])
sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] RWekajars_3.7.11-1 rJava_0.9-6 RWeka_0.4-23
[4] SnowballC_0.5 tm_0.6 NLP_0.1-3
[7] twitteR_1.1.8 devtools_1.5
loaded via a namespace (and not attached):
[1] bit_1.1-12 bit64_0.9-4 digest_0.6.4 evaluate_0.5.5
[5] grid_3.1.1 httr_0.4 memoise_0.2.1 parallel_3.1.1
[9] RCurl_1.95-4.1 rjson_0.2.14 slam_0.1-32 stringr_0.6.2
[13] tools_3.1.1 whisker_0.3-2