如何从R中的wordcloud中删除foriegn charcaterÃ

时间:2018-06-25 17:05:29

标签: r text-analysis word-cloud

rm(list=ls())
library(tm)
library(stringr)
posneg_corpus <- Corpus(Allwords, "C:/Users/Desktop/Text Analytics")
summary(posneg_corpus)
posnegclean_corpus <- tm_map(posneg_corpus, tolower)
posnegclean_corpus <- tm_map(posnegclean_corpus, removeNumbers)
posnegclean_corpus <- tm_map(posnegclean_corpus, removePunctuation)
posnegclean_corpus <- tm_map(posnegclean_corpus, stripWhitespace)
mystopwords <- c(stopwords("english"), "leave","part","self","getting"))
posnegclean_corpus <- tm_map(posnegclean_corpus, removeWords, mystopwords)
posnegclean_corpus <- replace(posnegclean_corpus, "Ã", " ")
library(wordcloud)
term_matrix <- TermDocumentMatrix(posnegclean_corpus)          
term_matrix <- as.matrix(term_matrix)
colnames(term_matrix) <- c(" ", " ", " ")
png("wordcloud_sprng 06212018.2.png", width=12,height=8, units='in', res=300)par(mar = rep(0, 4)) 
comparison.cloud(term_matrix, max.words = 200, scale=c(6,.2), random.order=F, rot.per=.15, colors = c("darkred", "gray", "darkgreen"), title.size = 0.01)

上面是代码。但是,“ cloud”一词仍在向我显示donÃ&itÃ。我认为这是一个编码问题。我尝试以相同的格式保存文本文件和R程序的编码。请帮忙。让我知道您是否需要其他信息。

0 个答案:

没有答案