r语言 - 单击操作按钮后创建词云



我想在用户单击按钮后重新运行Word Cloud的创建。目前它没有运行:(。该应用程序的基本原理是用户输入一些关键字(textInput(,然后单击(actionButton(后,它应该使用新提供的文本并运行代码。

SERVER.R
wc_data <- reactive({
input$Update
isolate({
withProgress({
setProgress(message = "Progressing corpus")
query<-get_sql_query(input$key)
wc_file <- dbGetQuery(con, query)
wc_file<-wc_file[,3]
wc_corpus<- Corpus(VectorSource(wc_file))
wc_corpus_clean<-tm_map(wc_corpus, tolower)
wc_corpus_clean<-tm_map(wc_corpus_clean, removeNumbers)
wc_corpus_clean<-tm_map(wc_corpus_clean, removeWords, stopwords::stopwords(language = "en", source = "stopwords-iso"))
wc_corpus_clean<-tm_map(wc_corpus_clean, stripWhitespace)
wc_corpus_clean<-tm_map(wc_corpus_clean, stemDocument)
})
})
})
wordcloud_rep<-repeatable(wordcloud)
output$wcplot<-renderPlot({
withProgress({
setProgress(message = "Creating wordcloud...")
wc_corpus<-wc_data()
#dev.new(width = 1000, height = 1000, unit = "px")
wordcloud(wc_corpus, max.words=input$max,min.freq = input$freq, scale=c(10,0.5), colors=brewer.pal(8,"Dark2"), random.order = F, rot.per = 0.35)
})
})
UI.R
textInput("key", label = "Enter the keywords on the basis of which Word Cloud will be created:", value = "search customer expensive"),
actionButton("Update","Update")

有什么想法如何实现它吗?

您使用的是renderPlot而不是renderWordcloud.您可以在此处找到更多信息。

最新更新