title: R Shiny - How do I toggle between two different plots using an action button
body: <p>In my app, I want plot1 to display by default, and then if an action button is clicked, have plot2 replace plot1. If it is clicked again, revert to plot1, and so on.</p>
  <pre><code>
  server &lt;- function(input, output, session) {
       plot1 &lt;- (defined here)
       plot2 &lt;- (defined here)
    
       which_graph &lt;- reactive({
          if (input$actionbutton == 1) return(plot1)
          if (input$actionbutton == 2) return(plot2)
        })
      
       output$plot &lt;- renderPlot({   
          which_graph()
      
        }) 
  } 
  </code></pre>