rshinydt

Warning: Error in dataTableOutput: unused argument (height = "auto")


Seeing inconsistent results with dataTableOutput (https://github.com/rstudio/DT). When I start shiny from an R console, the first time I run the app the height argument in dataTableOutput() causes the app to crash. If I then CTRL-C to stop shiny, then shiny::runApp(), then the app thenceforth works as expected. Not passing the height is okay locally. The box is filled in and sizes its height automatically. However, when loading the app on shinyapps.io, the box is always empty and has a small height (let's say 60px). No matter what I do on shinyapps.io, if the the height is, e.g., height=300, then the app will always crash. No CTRL-C will work on shinyapps.io. Sometimes the app will refuse to start locally when "height=300" is present, but if I comment out dataTableOutput completely, re-run shiny::runApp(), then bring dataTableOutput back without restarting shiny, then the app loads okay.

The error:

Warning: Error in dataTableOutput: unused argument (height = "200")
  100: h
   99: .handleSimpleError
   98: dots_list
   97: div
   96: dots_list
   95: div
   94: dots_list
   93: div
   92: box
   91: dots_list
   90: div
   89: fluidRow
   88: dots_list
   87: div
   86: column
   85: dots_list
   84: div
   83: fluidRow
   82: dots_list
   81: div
   80: tabItem
   79: lapply
   78: tabItems
   77: dots_list
   76: tags$section
   75: dots_list
   74: div
   73: dashboardBody
   72: tagAssert
   71: dashboardPage
   70: ..stacktraceon..
   69: eval
   68: eval
   67: sourceUTF8
   66: func
   65: uiHandlerSource
   64: handler
   63: handler
   62: handler
   61: handlers$invoke
   60: withCallingHandlers
   59: domain$wrapSync
   58: promises::with_promise_domain
   57: captureStackTraces
   56: withCallingHandlers
   55: withLogErrors
   54: withCallingHandlers
   53: force
   52: withVisible
   51: withCallingHandlers
   50: domain$wrapSync
   49: promises::with_promise_domain
   48: captureStackTraces
   47: doTryCatch
   46: tryCatchOne
   45: tryCatchList
   44: tryCatch
   43: do
   42: hybrid_chain
   41: force
   40: withVisible
   39: withCallingHandlers
   38: domain$wrapSync
   37: promises::with_promise_domain
   36: captureStackTraces
   35: doTryCatch
   34: tryCatchOne
   33: tryCatchList
   32: tryCatch
   31: do
   30: hybrid_chain
   29: handler
   28: func
   27: compute
   26: doTryCatch
   25: tryCatchOne
   24: tryCatchList
   23: tryCatch
   22: rookCall
   21: <Anonymous>
   20: evalq
   19: evalq
   18: doTryCatch
   17: tryCatchOne
   16: tryCatchList
   15: doTryCatch
   14: tryCatchOne
   13: tryCatchList
   12: tryCatch
   11: execCallbacks
   10: run_now
    9: service
    8: serviceApp
    7: ..stacktracefloor..
    6: withCallingHandlers
    5: domain$wrapSync
    4: promises::with_promise_domain
    3: captureStackTraces
    2: ..stacktraceoff..
    1: shiny::runApp

The code (two example boxes although one is enough to show the issue):

dashboardPage(
  dashboardHeader(title = 'Energy comparison'),
  dashboardSidebar(
    sidebarMenu(
      ...
      menuItem('Stacked', tabName = 'table', icon = NULL)
    )
  ),
  dashboardBody(
    tabItems(
      ...
      tabItem(
        tabName = 'table',
        fluidRow(
          column(6,
            fluidRow(
              box(title = 'Annual energy by source',
                solidHeader = TRUE, status = 'primary', width = 12,
                dataTableOutput('tab1') # Always works locally.
                                        # Doesn't crash shinyapps.io
                                        # but always show a tiny box
                                        # with no data.
              )
            )
          ),
          column(6,
            fluidRow(
              box(title = 'Annual energy by source %',
                solidHeader = TRUE, status = 'primary', width = 12,
                dataTableOutput('tab2', height="auto")
                  # height = "auto" or "300"
                  # Causes error sporadically locally.
                  # Can get it working locally by removing "height=..."
                  # then reloading the page while shiny is running.
                  # But this always crashes on shinyapps.io.
              )
            )
          )
        )
      )      
    )
  )
)

TAG: dataTableOutput


Solution

  • There are two functions of dataTableOutput, one which is present in shiny package which does not have height argument and another in DT package. I don't know if you are loading the DT package at all but it is better to mention explicitly that you want to use dataTableOutput from DT package.

    DT::dataTableOutput('tab2', height="auto")