我有一个从 rpivotTable 库生成的数据透视表。我正在使用闪亮的仪表板在一个框中显示数据透视表的输出。身材好像不太对。
下面是输出的截图。
我试图让盒子的大小与数据透视表的大小相匹配,如果数据透视表的大小更大,我就会有一个滚动条。但是背景颜色“皮肤蓝色”似乎不适合盒子的大小。
下面是一个示例代码:
用户界面
library(shiny)
library(shinydashboard)
library(rpivotTable)
header <- dashboardHeader(title="Dashboard")
sidebar <- dashboardSidebar(
menuItem("Menu1",icon = icon("dashboard"),
menuSubItem("Sub1", icon = icon("dashboard")),
menuSubItem("Sub2", icon = icon("dashboard")),
menuSubItem("Sub3", icon = icon("dashboard"))
),
menuItem("Menu2",icon = icon("dashboard"),
menuSubItem("Sub12", icon = icon("dashboard")),
menuSubItem("Sub22", icon = icon("dashboard")),
menuSubItem("Sub32", icon = icon("dashboard"))))
body <- dashboardBody(
tabItem(tab = "sub1",
box(width = 12,selectInput("testip",label = "Input",choices = c("A","B","C")),
selectInput("testip1",label = "Input",choices = c("A","B","C")),
selectInput("testip2",label = "Input",choices = c("A","B","C")),
actionButton("submit","Submit")),
box(width = 12,height = "800px",
tags$head(tags$style( type = 'text/css', '#myPivot{ overflow-x: scroll; overflow-y: scroll; }')),
rpivotTableOutput("myPivot", height = "780px")))
)
dashboardPage(header, sidebar, body)
服务器.R
server <- function(input, output) {
output$myPivot <- renderRpivotTable(rpivotTable(data = mtcars, rows = "mpg", cols = "disp"))
}