I'm creating a Shiny app where users can switch between different plots, based on a click on a radio button. I followed the suggestion of cmaher in this question, but I found that I can switch only once. The second time gives me a blank output.
Why doesn't shiny render the plot output again when clicking the button? And how to do this?
MWE:
server <- shinyServer(function(input, output, session) {
PlotA <- reactive({
    plot(-2:2, -2:2)
  })
PlotB <- reactive({
  plot(-1:1, -1:1)
})
PlotInput <- reactive({
  switch(input$PlotChoice,
         "A" = PlotA(),
         "B" = PlotB())
})
output$SelectedPlot <- renderPlot({ 
  PlotInput()
})
})
ui <-  shinyUI(fluidPage(
  navbarPage(title=" ",
     tabPanel("A",
        sidebarLayout(
           sidebarPanel(
              radioButtons("PlotChoice", "Displayed plot:", 
                            choices = c("A", "B"))),
          mainPanel(plotOutput("SelectedPlot")))))
  ,  fluid=TRUE))
shinyApp(ui=ui, server=server)
 
     
     
    