title: Change plotly chart y variable based on selectInput
body: <p>I'm creating a simple line chart which renders correctly in Shiny.</p>
  
  <p>I've now added a selectInput with the names of 2 different measures, written as they appear in my data set. I'd like my y variable to change accordingly.</p>
  
  <pre><code>p &lt;- plot_ly(data = LineChartData(), x= Calendar.Month, y = input$Measure, type = "line", group = Calendar.Year, col = Calendar.Year)
  </code></pre>
  
  <p>Unfortunately, the chart renders with just one point. It's not taking input$Measure and finding that field in my data set.</p>
  
  <p>I know when using ggplot, i'd switch my aes to aes_string. Is there a similar solution in plotly? </p>
  
  <p>EDIT: here's some reproducible code</p>
  
  <p>Here's the ui.R file</p>
  
  <pre><code>    #ui.R
  
  shinyUI(
    fluidPage(
      titlePanel("Inbound Intermediary Performance"),
  
    sidebarLayout(
      sidebarPanel(
      h4("Parameters"),
      br(),
      selectInput("Measure", "Measure", c("Var1","Var2"))
      ),
      mainPanel(
  
        plotlyOutput("lineChart")
  
        )
  
    )
  
          )
  
  )
  </code></pre>
  
  <p>server.R</p>
  
  <pre><code>#server.R
  library(plotly)
  library(shiny)
  library(ggplot2)
  
  
  
  
  
  #Create data
  data &lt;- data.frame(Month = c(1,2,3,4,5,6,7,8,9,10,11,12), Var1 = c(36,33,30,27,24,21,18,15,12,9,6,3), Var2 = c(4,8,12,16,20,24,28,32,36,40,44,48))
  
  
  
  shinyServer(function(input, output) {
  
  
    #Create plot
  
    output$lineChart &lt;- renderPlotly({
  
      #using ggplot
      p &lt;- ggplot(data=data, aes_string(x='Month', y = input$Measure)) +geom_line(size = 1.5) + theme_minimal()
      ggplotly(p)
  
  
  
      #Using PLotly
      #p &lt;- plot_ly(data = data, x= Month, y = input$Measure, type = "line")
  
    })
  
  })
  </code></pre>
  
  <p>In the example above, I can use my drop down to switch between Var1 and Var2. My plot changes accordingly. The code uses ggplot and it's aes_string function to take an input. This is then converted into a plotly interactive plot using the ggplotly function.</p>
  
  <p>Is there a way I can do this natively with plotly?</p>