library("tm")
library("twitteR")
library("wordcloud")
clean.text <- function(x, lowercase=TRUE, numbers=TRUE, punctuation=TRUE, spaces=TRUE)
{
# x: character string
# lower case
if (lowercase)
x = tolower(x)
# remove numbers
if (numbers)
x = gsub("[[:digit:]]", "", x)
# remove punctuation symbols
if (punctuation)
x = gsub("[[:punct:]]", "", x)
# remove extra white spaces
if (spaces) {
x = gsub("[ \t]{2,}", " ", x)
x = gsub("^\\s+|\\s+$", "", x)
}
# return
x
}
teste_word_cloud$text <- as.factor(teste_word_cloud$text)
ensaio1 = clean.text(teste_word_cloud$text)
teste_word_cloud2$text <- as.factor(teste_word_cloud2$text)
ensaio2 = clean.text(teste_word_cloud2$text)
teste_word_cloud3$text <- as.factor(teste_word_cloud3text)
ensaio3 = clean.text(teste_word_cloud3$text)
teste_word_cloud4$text <- as.factor(teste_word_cloud4text)
ensaio4 = clean.text(teste_word_cloud4$text)
e1 = paste(ensaio1, collapse=" ")
e2 = paste(ensaio2, collapse=" ")
e3 = paste(ensaio3, collapse=" ")
e4 = paste(ensaio4, collapse=" ")
all = c(e1,e2,e3,e4)
corpus = Corpus(VectorSource(all))
tdm = TermDocumentMatrix(corpus)
tdm = as.matrix(tdm)
colnames(tdm) = c("Ensaio 1", "Ensaio 2", "Ensaio 3", "Ensaio 4")
comparison.cloud(tdm, random.order=FALSE,
colors = c("#00B2FF", "red"),
title.size = 1.5, max.words = 500)
我想执行wordcloud比较,但是会发生此错误: strwidth错误(words [i],cex = size [i],...):无效的“ cex”值。从我读到的内容来看,我想这是因为不适用,但我找不到解决方案。谢谢您的帮助。