试图复制这里的例子;
http://onertipaday.blogspot.com/2011/07/word-cloud-in-r.html
需要帮助找出如何增加单词云的绘制面积.更改png(“wordcloud_packages.png”,width = 1280,height = 800)中的高度和宽度参数只会更改画布的高度和宽度,但绘制的区域仍然很小.
require(XML) require(tm) require(wordcloud) require(RColorBrewer) u = "http://cran.r-project.org/web/packages/available_packages_by_date.html" t = readHTMLTable(u)[[1]] ap.corpus <- Corpus(DataframeSource(data.frame(as.character(t[,3])))) ap.corpus <- tm_map(ap.corpus,removePunctuation) ap.corpus <- tm_map(ap.corpus,tolower) ap.corpus <- tm_map(ap.corpus,function(x) removeWords(x,stopwords("english"))) ap.tdm <- TermDocumentMatrix(ap.corpus) ap.m <- as.matrix(ap.tdm) ap.v <- sort(rowSums(ap.m),decreasing=TRUE) ap.d <- data.frame(word = names(ap.v),freq=ap.v) table(ap.d$freq) pal2 <- brewer.pal(8,"Dark2") png("wordcloud_packages.png",width=1280,height=800) wordcloud(ap.d$word,ap.d$freq,scale=c(8,.2),min.freq=3,max.words=Inf,random.order=FALSE,rot.per=.15,colors=pal2) dev.off()
解决方法
请改用res参数:
... png("wordcloud_packages.png",width=12,height=8,units='in',res=300) ...