我正在尝试为目录中的每个文本文件创建一个 wordcloud。它们是四次总统宣布演讲。我不断收到以下消息:
> cname <- file.path("C:", "texts")
> cname
[1] "C:/texts"
> cname <- file.path("C:\\Users\\BonitaW\\Documents\\DATA630\\texts")
> dir(cname)
[1] "berniesandersspeechtranscript20115.txt"
[2] "hillaryclintonspeechtranscript2015.txt"
[3] "jebbushspeechtranscript2015.txt"
[4] "randpaulspeechtranscript2015.txt"
> library(tm)
> docs <- Corpus(DirSource(cname))
> summary (docs)
Length
berniesandersspeechtranscript20115.txt 2
hillaryclintonspeechtranscript2015.txt 2
jebbushspeechtranscript2015.txt 2
randpaulspeechtranscript2015.txt 2
Class
berniesandersspeechtranscript20115.txt PlainTextDocument
hillaryclintonspeechtranscript2015.txt PlainTextDocument
jebbushspeechtranscript2015.txt PlainTextDocument
randpaulspeechtranscript2015.txt PlainTextDocument
Mode
berniesandersspeechtranscript20115.txt list
hillaryclintonspeechtranscript2015.txt list
jebbushspeechtranscript2015.txt list
randpaulspeechtranscript2015.txt list
> docs <- tm_map(docs, removePunctuation)
> docs <- tm_map(docs, removeNumbers)
> docs <- tm_map(docs, removeWords, stopwords("english"))
> library(SnowballC)
Warning message:
package ‘SnowballC’ was built under R version 3.1.3
> docs <- tm_map(docs, stemDocument)
> docs <- tm_map(docs, stripWhitespace)
> docs <- tm_map(docs, PlainTextDocument)
> dtm <- DocumentTermMatrix(docs)
> dtm
<<DocumentTermMatrix (documents: 4, terms: 1887)>>
Non-/sparse entries: 2862/4686
Sparsity : 62%
Maximal term length: 20
Weighting : term frequency (tf)
> tdm <- TermDocumentMatrix(docs)
> tdm
<<TermDocumentMatrix (terms: 1887, documents: 4)>>
Non-/sparse entries: 2862/4686
Sparsity : 62%
Maximal term length: 20
Weighting : term frequency (tf)
> library(wordcloud)
> Berniedoc <- wordcloud(names(freq), freq, min.freq=25)
Warning message:
In wordcloud(names(freq), freq, min.freq = 25) :
american could not be fit on page. It will not be plotted.
最初我能够绘制 Berniedoc,但丢失了图形,但现在无法绘制。
Berniedoc <- wordcloud(names(freq), freq, min.freq=25)
Warning messages:
1: In wordcloud(names(freq), freq, min.freq = 25) :
american could not be fit on page. It will not be plotted.
2: In wordcloud(names(freq), freq, min.freq = 25) :
work could not be fit on page. It will not be plotted.
3: In wordcloud(names(freq), freq, min.freq = 25) :
countri could not be fit on page. It will not be plotted.
4: In wordcloud(names(freq), freq, min.freq = 25) :
year could not be fit on page. It will not be plotted.
5: In wordcloud(names(freq), freq, min.freq = 25) :
new could not be fit on page. It will not be plotted.
6: In wordcloud(names(freq), freq, min.freq = 25) :
see could not be fit on page. It will not be plotted.
7: In wordcloud(names(freq), freq, min.freq = 25) :
and could not be fit on page. It will not be plotted.
8: In wordcloud(names(freq), freq, min.freq = 25) :
can could not be fit on page. It will not be plotted.
9: In wordcloud(names(freq), freq, min.freq = 25) :
time could not be fit on page. It will not be plotted.
你能告诉我我做错了什么吗?会不会是缩放?或者我应该把“伯尼多克”换成别的东西吗?