微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用R创建wordcloud时出错

如何解决使用R创建wordcloud时出错

我正在使用以下CSV文件用法语编写):

words_list= ["I","am","x","years","old"] # sentence having missing value as "x"
val = input("how many years old are you ?") # input the value of "x"
words_list[2] = val # replace the value of "x" at right place
print(' '.join(word for word in words_list)) # get the output with missing owrd at right place as sentence

我想用wordcloud2库创建一个wordcloud。

这是我写的R脚本:

"1";"Paul is in the kitchen"
"2";"Peter is cooking in the living-room"
"3";"The kitchen is beautiful"

但是出现以下错误

 data <- read.csv('file.csv',sep="|",quote="",header=TRUE)
 dim(data)
 library(tm)

 documents <- Corpus(VectorSource(data))
 inspect(documents)

 lapply(documents[1],as.character)
 inspect(documents)

 set.seed(1234)

 tdm <- TermDocumentMatrix(documents)
 m <- as.matrix(tdm)
 v <- sort(rowSums(m),decreasing=TRUE)
 d <- data.frame(freq = v)
 d$word=rownames(d)

 library("wordcloud2")
 wordcloud2(d)

您怎么看?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。