我想在用户单击按钮后重新运行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")
有什么想法要实现吗?