收缩DT :: dataTableOutput大小

Mil*_*Zhu 16 r shiny dt

我有一个闪亮的界面,我用DT::dataTableOutputDT::renderDataTable了很多.但是,我想知道是否有办法缩小数据表的大小,例如,使字体和表格更小.我该怎么做?

假设我有以下代码:

foo <- function(){
  shinyApp(
    ui = fluidPage(
      DT::dataTableOutput("table")
    ),

    server <- function(input, output) {
      x <- data.frame(1:5, 2:6)
      output$table <- DT::renderDataTable(x)
    }
  )
}
Run Code Online (Sandbox Code Playgroud)

我应该添加哪些选项或标签?

小智 17

尝试添加width: 75%到您的style参数div:

div(DT::dataTableOutput("table"), style = "font-size: 75%; width: 75%")
Run Code Online (Sandbox Code Playgroud)