title: how to create plotly line chart in shinyapp with multiple level variable
body: <p>Hi im trying to plot  simple chart using plotly in the Shiny app. It is a line chart with Frequency variable on the X-Axis and a Metric on y-axis. i'm expecting two lines in the charts as i'm calling in a variable that has two levels in the UI. i'm getting the chart when i have one input from the groupcheckbox, but the goes blank when i select two options. i dont know what i'm doing wrong here, I'm not getting any error notifications.thanks for your inputs in advance</p>
  <p>pasting the code with data here.</p>
  <pre><code>library(shiny)
  library(plotly)
  library(readxl)
  
  prod&lt;-c(&quot;BrandB&quot;, &quot;BrandA&quot;, &quot;BrandB&quot;, &quot;BrandA&quot;, &quot;BrandB&quot;, &quot;BrandA&quot;,&quot;BrandB&quot;,&quot;BrandA&quot;,&quot;BrandB&quot;,&quot;BrandA&quot;,&quot;BrandB&quot;,&quot;BrandA&quot;,&quot;BrandB&quot;,&quot;BrandA&quot;,&quot;BrandB&quot;,&quot;BrandA&quot;)
  Freq&lt;-c(&quot;W7&quot;,&quot;W7&quot;,&quot;W8&quot;,&quot;W8&quot;,&quot;W9&quot;,&quot;W9&quot;,&quot;W10&quot;,&quot;W10&quot;,&quot;W10&quot;,&quot;W10&quot;,&quot;W7&quot;,&quot;W7&quot;,&quot;W8&quot;,&quot;W8&quot;,&quot;W9&quot;,&quot;W9&quot;)
  Metric1&lt;-c(0.515,0.444,0.518,0.446,0.529,0.405,0.497,0.376,0.505,0.494,0.515,0.444,0.518,0.446,0.529,0.405)
  Cut&lt;-c(&quot;RBs&quot;,&quot;RBs&quot;,&quot;RBs&quot;,&quot;RBs&quot;,&quot;RBs&quot;,&quot;RBs&quot;,&quot;Total&quot;,&quot;Total&quot;,&quot;RBs&quot;,&quot;RBs&quot;,&quot;Total&quot;,&quot;Total&quot;,&quot;Total&quot;,&quot;Total&quot;,&quot;Total&quot;,&quot;Total&quot;)
  
  DF&lt;-data.frame(prod,Freq,Metric1,Cut)
  
  str(DF)
  
  DF$Brand&lt;-as.factor(DF$prod)
  DF$Wave&lt;-factor(DF$Freq,levels=c(&quot;W7&quot;,&quot;W8&quot;,&quot;W9&quot;,&quot;W10&quot;))
  
  #View(DF)
  
  ui &lt;- fluidPage(
      
      # useShinydashboard(),
      
      titlePanel(&quot;Dassy&quot;),
      
      fluidRow(
          
          column(3,
                 checkboxGroupInput(inputId = &quot;Prod&quot;, 
                                    label = &quot;Choose Fill For the Chart&quot;,
                                    choices = c(&quot;BrandA&quot; = &quot;BrandA&quot;,&quot;BrandB&quot; = &quot;BrandB&quot;),
                                    selected = &quot;BrandA&quot;
                 )),
          column(3,
                 selectInput(inputId = &quot;Cut&quot;, 
                             label = &quot;Choose Fill For the Chart&quot;,
                             choices = c(&quot;Total&quot; = &quot;Total&quot;,&quot;RBs&quot; = &quot;RBs&quot;),
                             selected = &quot;Total&quot;)
          ),actionButton(&quot;go_button&quot;, &quot;GO !&quot;)
      ),
      
      mainPanel(
          plotlyOutput(&quot;distPlot&quot;))
  )
  
  
  server &lt;- function(input, output) {
      
      observeEvent(input$go_button,{
          output$distPlot &lt;- renderPlotly({
              
              DF1 &lt;- reactive({
                  
                  DF%&gt;%filter(Cut == input$Cut &amp; prod == input$Prod)
              }
              )
             
              p1&lt;-plot_ly(DF1(),x=~Freq, y=~Metric1, color =  ~prod, width=1200, height=300)%&gt;% add_lines(line = list(shape = &quot;spline&quot;)) 
              p1&lt;-p1%&gt;%layout(yaxis=list(tickformat =&quot;%&quot;))
              
          })
          #observe Event
      })
      
  }
  #??plot_ly()
  
  shinyApp(ui = ui, server = server)
  
  </code></pre>
  <p><a href="https://i.stack.imgur.com/1cbUB.png" rel="nofollow noreferrer">With single option selected line graph generated</a></p>
  <p><a href="https://i.stack.imgur.com/YfRFx.png" rel="nofollow noreferrer">With two option selected blank chart gets generated </a></p>