I am getting this warning every time I run my shiny
App.
Warning in processWidget(instance) : renderDataTable ignores ... arguments when expr yields a datatable object; see ?renderDataTable
This is a reproducible example:
library(shiny)
library(DT)
ui <- fluidPage(
titlePanel("My app"),
sidebarLayout(
sidebarPanel(
),
mainPanel(
dataTableOutput("table")
)
)
)
server <- function(input, output, session) {
output$table <- renderDataTable({
datatable(
mtcars,
filter = list(position = 'top', clear = FALSE),
selection = "none", #this is to avoid select rows if you click on the rows
rownames = FALSE,
extensions = 'Buttons',
options = list(
scrollX = TRUE,
autoWidth = TRUE,
dom = 'Blrtip',
buttons =
list('copy', 'print', list(
extend = 'collection',
buttons = list(
list(extend = 'csv', filename = "file", title = NULL),
list(extend = 'excel', filename = "file", title = NULL)),
text = 'Download'
)),
lengthMenu = list(c(10, 30, 50, -1),
c('10', '30', '50', 'All'))
),
class = "display"
)
},rownames=FALSE)
}
shinyApp(ui, server)
I checked this post but I am not using the parameter filter
at the end. I am using it inside DT::datatable
. What is more, if I comment this line (filter = list(position = 'top', clear = FALSE)
), I am still getting the same warning. So it must be because of another reason.
Does anyone know how to fix it?
Thanks in advance
rownames
is not part of the arguments of DT::renderDataTable()
so it is passed in ...
in this function. But the documentation of DT::renderDataTable()
says:
...
[is] ignored when expr returns a table widget, and passed as additional arguments to datatable() when expr returns a data object
Here, you create a datatable
in renderDataTable()
so ...
(and hence rownames = FALSE
) is ignored. This argument is useless here so you can remove rownames = FALSE
and it will remove the warning.