title: How to switch between different ggplot types?
body: <p>I want to have an application which plots my data in different types (as Line, as dots, as boxplot).</p>
  <p>Let's consider my code :</p>
  <pre><code>library(shiny)
  library(quantmod)
  
  start &lt;- as.Date(&quot;2013-01-01&quot;)
  end &lt;- as.Date(&quot;2016-10-01&quot;)
  # Apple stock
  getSymbols(&quot;AAPL&quot;, src = &quot;yahoo&quot;, from = start, to = end)
  apple &lt;- AAPL$AAPL.Close
  
  ### Define UI for application
  ui &lt;- fluidPage(
  
    # Sidebar panel
    sidebarPanel(
      selectInput(&quot;type&quot;,
        label = &quot;1. Select plot type&quot;,
        choices = c(&quot;Line&quot; = &quot;geom_line()&quot;, &quot;Dot&quot; = &quot;geom_point()&quot;, &quot;Boxplot&quot; = &quot;geom_boxplot()&quot;),
        selected = 3
      )
    ),
  
    # Main Panel
    mainPanel(
      plotOutput(&quot;sp&quot;)
    )
  )
  
  
  
  
  
  server &lt;- function(input, output) {
    output$sp &lt;- renderPlot({
      colm &lt;- as.numeric(apple)
      ggplot() +
        aes(x = 1:length(colm), y = colm) +
        geom_line() +
        xlab(NULL)
    })
  }
  
  # Run the application
  shinyApp(ui = ui, server = server)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/0BOKP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0BOKP.png" alt="enter image description here" /></a></p>
  <p>And I'm not sure what sure I put in <code>server</code> to be able to switch between these different types. I tried to use <code>if</code> statement and <code>get(input$type)</code> but both options give me nothing more than errors.</p>
  <p>To summarize - How can I write my application so that I can switch between different plot types (Line, Dots, Boxplot) as shown in image ?</p>