1

I am working on an application that has a leaflet map and a DT data table in it. I set up both to have initial data in the map and table, then update if a specific user name in a dropdown or data range is selected.

The map is population fine. However, I get an error message, which shows in bright red, when the application is loading, that suggests there is an issue with the data table data...but then the data does load (I assume after the reactive component is done loading.

I would love to make this annoying red error go away and could you some help

    output$customer_table <- renderDT({ customer_data%>%
    select(Customer, Associate, Date, Travel)%>%
        datatable( extensions = 'Buttons', 
                   options = list(
                       dom = 'Bfrtip',
                       pageLength = 35,
                       buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
                   colnames = c('Customer', 'Associate', 'Date', 'Travel'))})

This has the initial unfiltered data, which is 269 rows long as suggested in the error message. I use the following reactive component (Which is pulling dates from a date input and they are coming in right as it does adjust appropriately based on the selector once the table finally draws). The start and end date are described by input$date[1] & Date < input$date[2]

    newData <- reactive({
    all = unique(map_data$associate)
    map_data <- map_data%>%
        filter(Date > input$date[1] & Date < input$date[2])%>%
        filter(
            if (input$associate == "All") {
                Associate %in% all
            } else {
                Associate==input$associate
            }
        ) 

})

then this data is passed into the reactive table to output to the application with the following:

    output$customer_table <- renderDT({ newData()%>%
        select(Customer, Associate, Date, Travel)%>%datatable( extensions = 'Buttons',
                                                       options = list(
                                                           dom = 'Bfrtip',
                                                           pageLength = 35,
                                                           buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
                                                       colnames = c('Customer', 'Associate', 'Date', 'Travel'))})

This is the message I get for a couple of seconds when the map is up, but the table has yet to renderenter image description here

I am not upset about the final layout, it looks fine, but this error message during initial loading is hideous and I would like to have it go away. And if there is an underlying flaw in how I am managing the table data causing this, I would love to know how to fix it. Thanks for your help

sconfluentus
  • 4,693
  • 1
  • 21
  • 40
  • 3
    Try to provide [minmal reproducible Shiny example](https://stackoverflow.com/questions/48343080/how-to-convert-a-shiny-app-consisting-of-multiple-files-into-an-easily-shareable). Meanwhile, you can try to add `req(input$date[1]);req(input$date[2]);req(input$associate)` in `reactive` – A. Suliman Dec 16 '19 at 18:32
  • It is completely impossible to do so...it is both huge and running over protected data. I included the code that is problematic...that is all that can be included, as is often the case with interactive stuff and big stuff – sconfluentus Dec 16 '19 at 18:37
  • thanks for the suggestions, I will try them out – sconfluentus Dec 16 '19 at 18:39
  • 2
    We don't need the actual app and data, we just need **minimal complete reproducible** app that mimic the actual problem. – A. Suliman Dec 16 '19 at 18:42
  • you are a God...that worked. Can you explain why that solved the problem? – sconfluentus Dec 16 '19 at 18:45
  • Happy to help. See `?shiny::req` – A. Suliman Dec 16 '19 at 18:47

0 Answers0