I am working on a Shiny app to let users select columns, filter rows, and download the result. I am using Data Tables to do this. The data file is moderately large and using client-side processing results in a fairly significant slowdown; however, using server side processing I am unable to get access to the filtered dataset.
In other words, when server=FALSE in renderDataTable(), input$foo_rows_all returns all filtered rows but when server=TRUE input$foo_rows_all returns just the rows on the currently displayed page, not all rows. How can I get access to all filtered rows when server = TRUE.
An example that shows the problem:
library(shiny)
library(dplyr)
library(DT)
dat<-data.frame(letters=c(rep("A",15),rep("B",5),rep("C",5)))
server<-shinyServer(function(input, output) {
#Returns filtered data
output$dat_false <- renderDataTable(dat,filter = "top",server = FALSE)
#Returns just the currently visible values
output$dat_true <- renderDataTable(dat,filter = "top",server = TRUE)
#This code modified from: https://yihui.shinyapps.io/DT-info/
output$x5 = renderPrint({
cat('\n\nAll rows with server = TRUE:\n\n')
cat(input$dat_true_rows_all, sep = ', ')
cat('\n\nAll rows with server = FALSE:\n\n')
cat(input$dat_false_rows_all, sep = ', ')
})
})
ui<-shinyUI(
fluidPage(
sidebarLayout(
sidebarPanel(verbatimTextOutput('x5')),
mainPanel(dataTableOutput("dat_true"),
dataTableOutput("dat_false"))
)
)
)
shinyApp(ui,server)