title: ggplotly Error in order: argument 1 is not a vector
body: <p>I am trying to use <code>ggplot2</code> with <code>plotly</code> in a <code>shiny</code> app in R. Following is the code I use:  </p>
  
  <pre><code># Loading the libraries ---------------
  library(shiny)
  library(tidyverse)
  library(plotly)
  
  # Global ----------------
  if (!exists('ds', envir = .GlobalEnv, inherits = FALSE)) {
     ds &lt;- readRDS("Analysis/Data/df_sim_updated.rds")
  }
  
  if (!exists('ado', envir = .GlobalEnv, inherits = FALSE)) {
    ado &lt;- readRDS("Analysis/Data/df_ADOs.rds")
  }
  
  ds &lt;- as_tibble(ds)
  file_ID &lt;- unique(ds$file.ID)
  ado_Name &lt;- c("ditiExpeon6", "VanC5", "NeonC4", "llacCadi3", "WhiteC2", 
                "Ford1", "BMWC10", "StarT7", "owT8Yell", "peC9Esca", "tarCWins13", 
                "rC11RoveLand", "F150C12", "CargoT4", "SemiT3", "RedT1", "RaceT11", 
                "BlueT5", "artTWalm9", "ghtTFrei10", "MoveT12", "WhiteT2", "ilT6Carg"
  )
  
  ado &lt;- as_tibble(ado)
  
  
  # Define UI for application --------------------
  ui &lt;- fluidPage(
  
     # Application title
     titlePanel("exploRing simulation"),
  
    # Sidebar 
     sidebarLayout(
        sidebarPanel(
          selectInput("fileid", label = h3("Select scenario"), 
                      choices = file_ID),
  
          selectInput("adoName", label = h3("Select ADO(s)"), 
                      multiple = TRUE, choices = ado_Name)
        ),
  
        # Main Panel
        mainPanel(
          uiOutput("FS"),
  
          plotlyOutput("plot1")
  
        )
     )
  )
  
  # Define server logic ---------------------------------
  server &lt;- function(input, output) {
  
    # Filter ds according to fileid
    data &lt;- reactive({ds %&gt;% filter(file.ID==input$fileid)})
  
    # Time Frame Slider
    output$FS &lt;- renderUI(
      sliderInput("fs", label = h3("Time Frame"), min = min(data()$frames), 
                  max = max(data()$frames), value = min(data()$frames), width = "800px")
    )
  
    # Position of OV at given time
    data2 &lt;- reactive({data() %&gt;% filter(frames==input$fs)})
  
    # Filter ado(s) according to fileid
    ado_data1 &lt;- reactive(ado %&gt;% 
                            filter(file.ID==input$fileid,
                                   ADO_name %in% input$adoName))
  
    # Position of ado at given time
    ado_data2 &lt;- reactive(ado_data1() %&gt;% 
                            filter(frames==input$fs))
  
    # Plot data
    output$plot1 &lt;- renderPlotly(
  
    ggplotly( ggplot() +
      geom_line(data=data(),
                 aes(x = x, y = y)) +
      geom_point(data = data2(),
                 aes(x = x, y = y), size = 2) +
      geom_line(data = ado_data1(),
                aes(x = pos.2, y = pos.1, color = ADO_name)) +
      geom_point(data = ado_data2(),
                 aes(x = pos.2, y = pos.1, color = ADO_name),
                 size = 2) +
      geom_hline(yintercept = 278, linetype="longdash") +
      geom_hline(yintercept = 278-16) +
      geom_hline(yintercept = 278+16) +
        labs(x = "Longitudinal Position",
             y = "Lateral Position") +
      theme_bw())
  
  
  
    )
  
  
  
  
  
  }
  
  # Run the application ---------------------------------
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <h1>Problem</h1>
  
  <p>Following is the error message that I get:  </p>
  
  <pre><code>&gt; runApp('exploRe')
  
  Listening on http://127.0.0.1:7666
  Warning: Error in filter_impl: incorrect length (0), expecting: 26826
  Stack trace (innermost first):
      109: &lt;Anonymous&gt;
      108: stop
      107: filter_impl
      106: filter_.tbl_df
      105: filter_
      104: filter
      103: function_list[[k]]
      102: withVisible
      101: freduce
      100: _fseq
       99: eval
       98: eval
       97: withVisible
       96: %&gt;%
       95: &lt;reactive:data2&gt; [C:\Users\my_username\Google Drive\DrivingSimulator\exploRe/app.R#65]
       84: data2
       83: fortify
       82: layer
       81: geom_point
       80: ggplotly
       79: ggplotly
       78: func
       77: origRenderFunc
       76: output$plot1
        1: runApp
  Warning: Error in order: argument 1 is not a vector
  Stack trace (innermost first):
      88: order
      87: [.data.frame
      86: [
      85: to_basic.GeomLine
      84: to_basic
      83: layers2traces
      82: gg2list
      81: ggplotly.ggplot
      80: ggplotly
      79: ggplotly
      78: func
      77: origRenderFunc
      76: output$plot1
       1: runApp  
  </code></pre>
  
  <p>If I just use <code>renderPlot</code> and <code>plotOutput</code>, the app works fine. What am I doing wrong here?</p>