R与Spotfire的集成

时间:2014-03-27 17:54:33

标签: r integration spotfire

是否有人尝试将R​​与spotfire集成以在Spotfire中运行worcloud代码(使用操作控件)? 谁能告诉我以下代码有什么问题?我在Spotfire中运行时遇到错误。 R&是否有任何特定版本?我需要使用Spotfire来集成它吗?

我所做的wordcloud代码是:

library (worcloud)
library (Rcolorbrewer)
library (tm)
Data = read.csv("Test.csv")
xkcd.corpus <- Corpus(DataframeSource(data.frame(Data[, 1])))
xkcd.corpus <- tm_map(xkcd.corpus, removePunctuation)
xkcd.corpus <- tm_map(xkcd.corpus, tolower)
xkcd.corpus <- tm_map(xkcd.corpus, function(x) removeWords(x, stopwords("english")))
tdm <- TermDocumentMatrix(xkcd.corpus)
m <- as.matrix(tdm)
v <- sort(rowSums(m),decreasing=TRUE)
d <- data.frame(word = names(v),freq=v)
pal <- brewer.pal(9, "BuGn")
pal <- pal[-(1:2)]
png("wordcloud.png", width=1280,height=800)
wordcloud(d$word,d$freq, scale=c(8,.3),min.freq=2,max.words=100, random.order=T,           rot.per=.15, colors=pal, vfont=c("sans serif","plain"))
dev.off()

0 个答案:

没有答案