我试图利用LDAvis版本0.3.1附带的闪亮集成。 github(https://github.com/cpsievert/LDAvis/tree/master/inst/examples/shiny)上给出的示例是:
library(LDAvis)
library(shiny)
server <- shinyServer(function(input, output, session) {
output$myChart <- renderVis({
with(TwentyNewsgroups,
createJSON(phi, theta, doc.length, vocab, term.frequency,
R = input$nTerms))})
})
ui <- shinyUI(
fluidPage(
sliderInput("nTerms", "Number of terms to display", min = 20, max = 40, value = 30),
visOutput('myChart')
)
)
shinyApp(ui = ui, server = server)
这个应用程序不会渲染任何输出,所以我有点困惑。任何人都可以帮助解决如何将LDAvis集成到闪亮的应用程序中的最小示例吗?
答案 0 :(得分:2)
这段代码在我的机器上运行,但javascript需要一些时间才能完成(大约20秒)。这对你有帮助吗?
library(shiny)
library(LDAvis)
data(TwentyNewsgroups, package = "LDAvis")
ui <- shinyUI(
fluidPage(
sliderInput("nTerms", "Number of terms to display", min = 20, max = 40, value = 30),
visOutput('myChart')
)
)
server <- shinyServer(function(input, output, session) {
output$myChart <- renderVis({
if(!is.null(input$nTerms)){
with(TwentyNewsgroups,
createJSON(phi, theta, doc.length, vocab, term.frequency,
R = input$nTerms))
}
})
})
shinyApp(ui = ui, server = server)