rstudio / DT

R Interface to the jQuery Plug-in DataTables
https://rstudio.github.io/DT/
Other
587 stars 184 forks source link

`renderDT()` evaluates `...` in `expr`'s `env` #1129

Closed cpsievert closed 3 months ago

cpsievert commented 3 months ago

The reprex below results in Error in argFunc: object 'opts' not found since renderDT() evaluates its ... in env, which is likely wrong when quoted = TRUE. I'll send a PR to fix this.

BTW, I stumbled across in this in my efforts to address https://github.com/rstudio/shiny/issues/3986. As a part of that, we're hoping to deprecate shiny::renderDataTable() in favor of DT::renderDT() (and, by default, have shiny::renderDataTable() call out to DT::renderDT() if available). This issue presents a challenge to doing that properly, so a CRAN release with this fix would be very much appreciated. (cc @jcheng5)

library(shiny)
library(DT)

dat <- mtcars
expr <- quote(dat)
env <- environment()

ui <- fluidPage(
  DT::DTOutput("dt")
)

server <- function(input, output, session) {
  opts <- list()
  output$dt <- DT::renderDT(expr, quoted = TRUE, env = env, options = opts)
}

shinyApp(ui, server)