在 R 中使用 DT 调整数据表的宽度
Posted
技术标签:
【中文标题】在 R 中使用 DT 调整数据表的宽度【英文标题】:Adjusting the width of the datatable using DT in R 【发布时间】:2018-03-24 09:06:08 【问题描述】:这是在 R shiny 中创建的数据表的脚本。我正在尝试通过调整绘图的宽度来将绘图完全放入框中。下面是情节的脚本以及我试图适应的盒子。请帮助我调整使用数据表生成的图的宽度。另外,我不想增加盒子的宽度。指向可能解决方案的链接将有很大帮助。谢谢。
数据表脚本:
r3_blood = subset(patient, handling == "Blood test" & employee == "r3")
datatable(r3_blood, options = list(
searching = FALSE,
pageLength = 5,
lengthMenu = c(5, 10, 15, 20)
))
将表格放入框中的脚本:
box( title = "Case Summary", status = "primary", height =
"575",solidHeader = T,
dataTableOutput("sankey_table"))
【问题讨论】:
您可能对此***.com/questions/31921238/…感兴趣 Shrink DT::dataTableOutput Size的可能重复 【参考方案1】:1) 连同已经提议的possible duplicate
ticket,您可以在其中使用div(DT::dataTableOutput("table"), style = "font-size: 75%; width: 75%")
2) 您也可以将scrollX = T
添加到您的选项中
library(DT)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(),
dashboardBody(
box(title = "Case Summary", width = 4,status = "primary", height = "575",solidHeader = T, dataTableOutput("Table"))
)
)
server <- function(input, output, session)
output$Table <- renderDataTable(
datatable(mtcars, options = list(searching = FALSE,pageLength = 5,lengthMenu = c(5, 10, 15, 20), scrollX = T))
)
shinyApp(ui, server)
【讨论】:
以上是关于在 R 中使用 DT 调整数据表的宽度的主要内容,如果未能解决你的问题,请参考以下文章
在 R Shiny 中调整 Plotly::subplot 的高度和宽度