DT datatables not updating when normal data tables work fine

So I'm writing quite a complicated application which resets the value of fileInput and its associated dataframe in a manner like in this post https://groups.google.com/d/msg/shiny-discuss/HbTa4v612FA/AJ-R3WB7BAAJ. To do this I need to use reactiveValues to store the data

I'm having problems with the renderDT function not updating itself if the first fileInput throws an error (I've programmed the server to check the file to see if it's corrupted).

It's all very complicated but I've narrowed down the problem to the use of renderDT. If I use ordinary tables it works as expected. I've made two Shiny apps to illustrate the problem. The first one works fine and the second one doesn't. I'm totally stumped, I can't for the life of me think what the difference is.

Here's one that works (apologies the top of the code will WRITE A CSV FILE TO YOUR WORKING DIRECTORY- this is to give you something to feed into the file input)


library(shiny)
library(DT)

testFrame = data.frame("a" = c(1, 2), "b" = c(3, 4))

write.csv(testFrame, "temp.csv")

ui <- fluidPage(
  
  sidebarLayout(
    sidebarPanel(
      fileInput("file",
                "Choose file")
    ),
    
    mainPanel(
      tableOutput("theData")
    )
  )
)

server <- function(input, output) {
  
  rv <- reactiveValues(data = NULL, message = NULL)
  
  observe({
    
    validate(
      need(!is.null(input$file), "Input data")
    )
    
    rv$data = read_csv(input$file$datapath)
  })
  
  output$theData = renderTable({

    rv$data
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

Whereas this one, which is the same code except using renderDT and DTOutput, does not work at all


library(shiny)
library(DT)

testFrame = data.frame("a" = c(1, 2), "b" = c(3, 4))

write.csv(testFrame, "temp.csv")

ui <- fluidPage(
  
  sidebarLayout(
    sidebarPanel(
      fileInput("file",
                "Choose file")
    ),
    
    mainPanel(
      DTOutput("theData")
    )
  )
)

server <- function(input, output) {
  
  rv <- reactiveValues(data = NULL, message = NULL)
  
  observe({
    
    validate(
      need(!is.null(input$file), "Input data")
    )
    
    rv$data = read_csv(input$file$datapath)
  })
  
  output$theData = renderDT({
    
    rv$data
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

Help!

This is what I saw when I ran your DT code:

Here is my info:

R version 3.4.2 (2017-09-28)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] readr_1.1.1 DT_0.4      shiny_1.0.5

Oh my god, that's what it was, my DT package was out of date. Should have thought of that!

Thank you!

A post was split to a new topic: DT tables not updating while other tables are