You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the data source is a tbl_lazy from dplyr, DT fails to render, returns error message.
Error in datatable: 'data' must be either a matrix or a data frame
There's no error with shiny::renderTable, because it calls collect(). But DT::renderDataTable should not call collect() on the whole data source, because its rendered data table can be paginated and filtered, i.e., the data can be collected lazily.
con <- DBI::dbConnect(...) # same with pool::dbPool(...)
ui <- fluidPage(
DT::dataTableOutput("tbl")
)
server <- function(input, output, session) {
dat <- reactive({
con %>%
tbl("mytable"))
})
output$tbl <- DT::renderDataTable({
dat()
})
}
shinyApp(ui, server)
The text was updated successfully, but these errors were encountered:
Bug: the error message is unclear. It would be helpful to suggest that the user should call collect() when the input is a tbl_lazy.
Request for enhancement: when the input is a tbl_lazy, in interactive mode, in the R console, the input still displays ten lines of the tibble. Similarly, DT could display ten lines, and provide a button to display ten more lines, i.e., paginate the lazy tibble. DT already paginates a non-lazy tibble by default, so this would extend pagination to the lazy tibble.
For 2, I think it is more challenging but is what I was interested to do (#194). Currently DT does not take advantage of databases at all, and it definitely should. The implementation is probably not trivial, though.
When the data source is a
tbl_lazy
from dplyr, DT fails to render, returns error message.There's no error with
shiny::renderTable
, because it callscollect()
. ButDT::renderDataTable
should not callcollect()
on the whole data source, because its rendered data table can be paginated and filtered, i.e., the data can be collected lazily.The text was updated successfully, but these errors were encountered: