cpsievert / LDAvis

R package for web-based interactive topic model visualization.
Other
556 stars 134 forks source link

When put two ldavis output into one shinyapp, the second one cannot be reactive? #88

Open robinlish opened 6 years ago

robinlish commented 6 years ago

Thank you for your answers in advance!

The following is an example:

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))})

output$myChart1 <- 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'), sliderInput("nTerms", "Number of terms to display", min = 20, max = 40, value = 30), visOutput('myChart1') ) )

shinyApp(ui = ui, server = server)

harelhan commented 6 years ago

I am also running into the exact same issues. I also ran the above code and noticed that the lambda slider for second output is linked to the first output only. Seems like Lambda slider component doesn't know which output has made the call.

harelhan commented 6 years ago

Hi @cpsievert Sorry to bug you. Just read on some other issues that issue of multiple outputs to Shiny has been fixed. Wanted to confirm you if that is indeed the case as I still am getting the same error.

Thanks Hitesh

ismirsehregal commented 3 years ago

Fixed your slider id's:

library(LDAvis)
library(shiny)

ui <- shinyUI(
  fluidPage(
    sliderInput("nTerms1", "Number of terms to display", min = 20, max = 40, value = 30),
    visOutput('myChart1'),
    sliderInput("nTerms2", "Number of terms to display", min = 20, max = 40, value = 30),
    visOutput('myChart2')
  )
)

server <- shinyServer(function(input, output, session) {
  output$myChart1 <- renderVis({
    with(TwentyNewsgroups,
         createJSON(phi, theta, doc.length, vocab, term.frequency,
                    R = input$nTerms1))})

  output$myChart2 <- renderVis({
    with(TwentyNewsgroups,
         createJSON(phi, theta, doc.length, vocab, term.frequency,
                    R = input$nTerms2))})
})

shinyApp(ui = ui, server = server)

This is what happens: screen