0

I have two ggraph plots - graph1 and graph2 and I want graph1 to be shown when the dropdown item "1" is chosen and graph2 to be shown when the dropdown item "2" is being chosen. But, reactive is not displaying any of the plots on the chosen values. I'm using the following code snippet in server.UI

shinyServer( function(input, output, session) {

    inData <- reactive({
        if ("1" %in% input$in) return(graph1)
        if ( "2" %in% input$in) return(graph2)
        })
    output$plot <- renderPlot(
        inData)
})

Here is the UI.R file

shinyUI(fluidPage(
    titlePanel("Test"),
    sidebarLayout(
        sidebarPanel(
            selectInput("in", 'Choose', choices = list("1","2"))),
        mainPanel(
            plotOutput("plot")
        )
    )
))

If I directly put

output$plot <- graph1

The graph1 is displayed correctly.

I think there is some problem here ??

if ("1" %in% input$in) return(graph1)
if ( "2" %in% input$in) return(graph2)
maxomax
  • 119
  • 5

0 Answers0