6
私は感想を生成するためにtwitter APIを使用しています。私はつぶやきに基づいて単語雲を生成しようとしています。このためWordcloudがテキストを切り取っています
pal <- brewer.pal(8,"Dark2")
wordcloud(clean.tweets,min.freq = 125,max.words = Inf,random.order = TRUE,colors = pal)
結果:
私もこれを試してみました:ここ
は、このためにwordcloud
wordcloud(clean.tweets, random.order=F,max.words=80, col=rainbow(50), scale=c(3.5,1))
の検索結果を生成するために私のコードです
何か不足していますか?
これは私がつぶやきを取得し、清掃しています方法です:事前に
#downloading tweets
tweets <- searchTwitter("#hanshtag",n = 5000, lang = "en",resultType = "recent")
# removing re tweets
no_retweets <- strip_retweets(tweets , strip_manual = TRUE)
#converts to data frame
df <- do.call("rbind", lapply(no_retweets , as.data.frame))
#remove odd characters
df$text <- sapply(df$text,function(row) iconv(row, "latin1", "ASCII", sub="")) #remove emoticon
df$text = gsub("(f|ht)tp(s?)://(.*)[.][a-z]+", "", df$text) #remove URL
sample <- df$text
# Cleaning Tweets
sum_txt1 <- gsub("(RT|via)((?:\\b\\w*@\\w+)+)","",sample)
sum_txt2 <- gsub("http[^[:blank:]]+","",sum_txt1)
sum_tx3 <- gsub("@\\w+","",sum_txt2)
sum_tx4 <- gsub("[[:punct:]]"," ", sum_tx3)
sum_tex5 <- gsub("[^[:alnum:]]", " ", sum_tx4)
sum_tx6 <- gsub("RT ","", sum_tex5)
# WordCloud
# data frame is not good for text convert it corpus
corpus <- Corpus(VectorSource(sum_tx6))
clean.tweets<- tm_map(corpus , content_transformer(tolower)) #converting everything to lower cases
clean.tweets<- tm_map(guj_clean,removeWords, stopwords("english")) #stopword are words like of, the, a, as..
clean.tweets<- tm_map(guj_clean, removeNumbers)
clean.tweets<- tm_map(guj_clean, stripWhitespace)
ありがとう!
clean.tweetオブジェクトの作成に使用したコードを共有できますか?私は自分のマシンにワードクラウドを作成するpblmを持っていません。 'par()'オプションを指定してしまったことはありますか? –
@ColinFAY更新された質問をご確認ください。私は自分のコードでpar()を使用していない –