R interface to wordcloud for data visualization. Timdream's wordcloud2.js is used in this package.
devtools::install_github("lchiffon/wordcloud2")
knitr and shiny is support in wordcloud2 package.
library(wordcloud2)
wordcloud2(demoFreq, size = 1,shape = 'star')
wordcloud2(demoFreq, size = 2, minRotation = -pi/2, maxRotation = -pi/2)
wordcloud2(demoFreq, size = 2, minRotation = -pi/6, maxRotation = -pi/6,
rotateRatio = 1)
## Sys.setlocale("LC_CTYPE","eng")
wordcloud2(demoFreqC, size = 2, fontFamily = "微软雅黑",
color = "random-light", backgroundColor = "grey")
Thanks JacobXPX's contribution to this feature:
Thanks AdamSpannbauer for pointing out the issues.
Additional features are added or modified:
hover information display are fixed, refering AdeelK93's previous work, thanks!
multiple wordclouds which seperatedly click are supported.
clickedWordInputId
is changed to be automatically generated by: paste0(outputId, "_clicked_word")).
See sample below for more details:
library(shiny)
library(wordcloud2)
shinyApp(
ui=shinyUI(fluidPage(
#using default clicked word input id
wordcloud2Output("my_wc", width = "50%", height = "400px"),
#using custom clicked word input id
wordcloud2Output("my_wc2", width = "50%", height = "400px"),
verbatimTextOutput("print"),
verbatimTextOutput("print2")
)),
server=shinyServer(function(input,output,session){
figPath = system.file("examples/a.png",package = "wordcloud2")
output$my_wc = renderWordcloud2(wordcloud2(data = demoFreq, figPath = figPath, size = 0.4,color = "blue"))
output$my_wc2 = renderWordcloud2(wordcloud2(demoFreq))
#using default clicked word input id
output$print = renderPrint(input$my_wc_clicked_word)
#using custom clicked word input id
output$print2 = renderPrint(input$my_wc2_clicked_word)
})
)
run the above code and click refresh, it will work.