2
votes

I am trying to create a wordcloud from the tweets I have mined useing twitteR. I have used the csv file containg the tweets sans formatting as input for the same. Following is my code:

library(tm)
library(plyr)
library(SnowballC)
library(wordcloud)
fk <-read.csv('onlyTweets.csv',colClasses="character",stringsAsFactors= FALSE, skipNul= TRUE)
fkCorpus<- Corpus(VectorSource(fk))
fkCorpus <- tm_map(fkCorpus,
                     content_transformer(function(x) iconv(x, to="", sub='byte')),
                     mc.cores=1)

fkCorpus <- tm_map(fkCorpus, content_transformer(tolower), lazy= TRUE, mc.cores= 1)
fkCorpus<- tm_map(fkCorpus, content_tranfformer(PlainTextDocument), lazy= TRUE,mc.cores= 1)
fkCorpus<- tm_map(fkCorpus, content_tranfformer(removePunctuation), lazy= TRUE, mc.cores=1)
fkCorpus<- tm_map(fkCorpus, content_tranfformer(removeNumbers), lazy= TRUE, mc.cores= 1)
fkCorpus <- tm_map(fkCorpus,removeWords , c(stopwords("english"),'the','flipkart','bigbillionsale','was'), lazy= TRUE, mc.cores=1)
fkCorpus<- tm_map(fkCorpus, stemDocument, lazy= TRUE,mc.cores= 1)
wordcloud(fkCorpus, max.words=75)#, random.order= FALSE)

I get the following 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

my sessionInfo()

R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

locale:
 [1] LC_CTYPE=en_IN.UTF-8       LC_NUMERIC=C               LC_TIME=en_IN.UTF-8       
 [4] LC_COLLATE=en_IN.UTF-8     LC_MONETARY=en_IN.UTF-8    LC_MESSAGES=en_IN.UTF-8   
 [7] LC_PAPER=en_IN.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_IN.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] wordcloud_2.5      RColorBrewer_1.1-2 SnowballC_0.5.1    plyr_1.8.3        
[5] tm_0.6-2           NLP_0.1-8         

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.2      twitteR_1.1.9    slam_0.1-32      grid_3.2.3       R6_2.1.2        
 [6] gtable_0.1.2     DBI_0.3.1        scales_0.3.0     ggplot2_2.0.0    httr_1.1.0      
[11] rjson_0.2.15     tools_3.2.3      bit64_0.9-5      munsell_0.4.2    bit_1.1-12      
[16] parallel_3.2.3   colorspace_1.2-6

I have gone through similar questions, and as suggested have put lazy=TRUE and mc.cores=1 and have used content_transformer wherever I could, but none of the answers have worked. Please help.

1

1 Answers

0
votes

I know you may have figured out a way to do it by yourself, but if you haven't and if you are still trying to search for the same. Do the below:

fkCorpus <- tm_map(fkCorpus,removeWords,stopwords("english"),lazy=TRUE, mc.cores=1)
fkCorpus <- tm_map(fkCorpus,removeWords,c("the","flipkart","bigbillionsale","was"),lazy=TRUE, mc.cores=1)

and it should work :) all the best let me know if it doesn't work!!