是否有可能使用wordcloud2包返回wordcloud中任何单词的单击作为闪亮的单击事件,以便将其他对象(例如bsModal)绑定到它?例如,在图中,这是通过生成可以从闪亮会话内访问的对象并保存事件数据(例如,点击坐标)(https://plot.ly/r/shinyapp-linked-click/)来实现的.
在下面的示例中,我想将bsModal绑定到wordcloud,以便显示用户单击的单词.
ui.R
library(shiny)
shinyUI(fluidPage(
mainPanel(
wordcloud2Output("wordcloud")
)
))
Run Code Online (Sandbox Code Playgroud)
server.R
library(shiny)
library(wordcloud2)
library(tm)
shinyServer(function(input, output) {
words <- c ("1st", "2nd", "3rd", "4th", "5h", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th",
"21st", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th")
random_words <- sample(words, 500, replace = TRUE)
docs <- Corpus(VectorSource(random_words))
dtm <- TermDocumentMatrix(docs)
m <- as.matrix(dtm)
v <- sort(rowSums(m),decreasing=TRUE)
d <- data.frame(word = names(v),freq=v)
wordcloud_plot <- wordcloud2(data = d, …Run Code Online (Sandbox Code Playgroud)