I have a question about datatable (DT) which i am using in Shiny.
I got quite big data (>5000000 rows), and i display it in shiny app using datatable (DT) with filters. Depending on the user preferences for filtering, lets assume it gives us 550 rows (but it can give us more or less than that). Because of pagination I am not able to see all 550 rows (assuming pageLength is 100) or whats even worse, i am not able to display all filtered rows further in a plot, as function input$tabelle_rows_all
uses the rows on the current page (i must first change the entries number).
Is there any way to get all found rows after filtering datatable (not depended on pageLength
)?
Example:
library(shiny)
library(DT)
library(ggplot2)
x <- as.numeric(1:1000000)
y <- as.numeric(1:1000000)
data <- data.frame(x,y)
shinyApp(
ui = fluidPage(dataTableOutput('tableId'),
plotOutput('plot1')),
server = function(input, output) {
output$tableId = renderDataTable({
datatable(data, options = list(pageLength = 100, lengthMenu=c(100,200,300,400,500,600)))
})
output$plot1 = renderPlot({
filtered_data <- data[input$tableId_rows_all, ]
ggplot(data=filtered_data, aes(x=x,y=y)) + geom_line()
})
}
)
Thanks for any Info
Are you sure it's not working already? As of version 0.0.65, you should have the following:
input$tableId_rows_current: the indices of rows on the current page
input$tableId_rows_all: the indices of rows on all pages (after the table is filtered by the search strings)
From the DT documentation
I'm using tableId_rows_all in a dashboard for exactly this and it is working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With