2017-10-12 123 views
1

這是在R shiny中創建的數據表的腳本。我試圖通過調整繪圖的寬度來完全適合框內的繪圖。下面是劇情的腳本,以及我試圖適應的那個框。請幫我調整使用數據表生成的圖的寬度。另外,我不想增加框的寬度。一個可靠的解決方案的鏈接將有很大的幫助。謝謝。在R中使用DT調整數據表的寬度

腳本的數據表:

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

DataTable

+1

你可能有興趣在這個https://stackoverflow.com/questions/31921238/shrink-dtdatatableoutput-size – Gonzo

+0

可能重複[Shrink DT :: dataTableOutput Size](https://stackoverflow.com/questions/31921238/shrink-dtdatatableoutput-size) – Gonzo

回答

1

1)隨着已經提出possible duplicateticket在那裏你可以使用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) 

enter image description here