我正在使用R Shinydashboard创建一个Shiny应用程序,我想并排显示两个输出,但是如果另一个输出太大,则迫使其中一个输出低于下面。
下面的代码创建了一个功能强大的闪亮应用程序,但是,如果您添加变量,则关联表会变大并显示在热图下:
library(easypackages)
libraries("readxl", "tidyselect", "DT", "shiny", "treemap", "plm", "shinydashboard", "data.table", "formattable", "plotly", "FactoMineR", "factoextra")
ui <- dashboardPage(
dashboardHeader(title = "test with mtcars", titleWidth = 1000),
dashboardSidebar(
selectizeInput("var.cor", label = "Correlation",
choices = names(mtcars),
selected = c("mpg", "cyl"), multiple = TRUE)
),
dashboardBody(
tabsetPanel(
tabPanel("test with mtcars",
box(dataTableOutput("cor"),
width = 6),
box(plotlyOutput("heat"),
width = 6)
)
)
)
)
server <- function(input, output) {
var.selected <- reactive({
out <- input$var.cor
out
})
user.selection <- reactive({
mtcars <- mtcars[, var.selected()]
})
output$cor <- renderDataTable({
dtable <- user.selection()
tmp <- round(cor(dtable, use = "complete.obs", method = "pearson"), 2)
tmp
})
output$heat <- renderPlotly({
dtable <- user.selection()
tmp <- as.matrix(cor(dtable, use = "complete.obs", method = "pearson"))
plot_ly(x = rownames(tmp), y = colnames(tmp), z = tmp, type = "heatmap", color = I("red"))
})
}
shinyApp(ui, server)
当关联表变得太大时,是否可以在关联表下自动显示热图,同时当两个输出放在一起时并排保持它们并排?