R 闪亮数据 table 隐藏 table 顶部的 "Show Entries" 标签,但不隐藏下拉框

R Shiny data table hide the "Show Entries" label on top of the table but not dropdown box

请使用以下代码显示数据table:

fluidRow(column(3,
                dataTableOutput(outputId="table01", width = '100px')))

渲染的 table 是这样创建的:

output$table01 <- DT::renderDataTable({  
  df <- get_mp_data()
  if(is.null(df)){
        df <- data.frame()
  }else{
        upcolor = "lightblue"
        downcolor = "lightblue"
        col_name = "CHG"
        df <- datatable(df
                        , rownames = FALSE 
                        , caption = paste0("Pre/Post Duration")
                        , filter = 'none'
                        , options = list(scrollX = F
                                         #, lengthChange = FALSE  # this feature hides the "Show Entries" on top of the table, so we won't be able to customize how many entries we can see all together
                                         , pagingType = "numbers"  # this hides the Next and Previous buttons -->  https://datatables.net/reference/option/pagingType
                                        , autoWidth = T
                                        ,pageLength = 5 # this determines how many rows we want to see per page
                                        , info = FALSE #  this will hide the "Showing 1 of 2..." at the bottom of the table -->  
                                        ,searching = FALSE  # this removes the search box  ->  
                                        ,columnDefs = list(list(width = '4', targets = c(3) ) 
                                                           ,list(width = '4', targets = c(2) )
                                                           )   # careful, column counting STARTS FROM 0 !
                                        )) %>% 
              formatStyle(col_name,
                          #background = styleColorBar(range(df[, c(col_name)]), 'lightblue'),
                          background = color_from_middle(df[, c(col_name)] , downcolor,   upcolor),
                          backgroundSize = '98% 88%',
                          backgroundRepeat = 'no-repeat',
                          backgroundPosition = 'center')
  }
  return(df)
})

此代码的问题在于它在 table 的左上角显示了“显示条目”,这占用了很多无用的 space。我只想保留下拉菜单并隐藏文本“显示条目”。 我在这里# https://datatables.net/reference/option 找不到任何关于此的内容。 请注意我不想使用“lengthChange = FALSE”,因为这也会隐藏允许自定义可以一起显示多少行的下拉框。 谢谢

您可以使用此选项:

datatable(iris, options = list(
  language = list(lengthMenu = "_MENU_")
))