警告:dataTableOutput 错误:未使用的参数(高度 = "auto")

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

看到与 dataTableOutput (https://github.com/rstudio/DT) 不一致的结果。当我从 R 控制台启动 shiny 时,我第一次 运行 应用程序 dataTableOutput() 中的高度参数导致应用程序崩溃。如果我然后 CTRL-C 停止闪亮,然后 shiny::runApp(),那么此应用程序将按预期工作。不超过高度在当地是可以的。框被填充并自动调整其高度。但是,在 shinyapps.io 上加载应用时,框总是空的并且高度很小(假设为 60 像素)。无论我在 shinyapps.io 上做什么,如果高度是 height=300,那么应用程序总是会崩溃。 shinyapps.io 上没有 CTRL-C。有时当“height=300”存在时app会拒绝在本地启动,但是如果我把dataTableOutput完全注释掉,重新运行shiny::runApp(),然后不重启就把dataTableOutput带回来闪亮,然后应用加载正常。

错误:

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

代码(两个示例框虽然一个足以说明问题):

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.
              )
            )
          )
        )
      )      
    )
  )
)

标签: dataTableOutput

dataTableOutput有两个函数,一个在shiny包中,没有height参数,另一个在DT包中。我不知道你是否正在加载 DT 包,但最好明确提及你想使用 DT 包中的 dataTableOutput

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