Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
robinlish opened this issue Apr 29, 2018 · 3 comments

Comments

@robinlish
Copy link

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
Copy link

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
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants