我有一个闪亮的应用程序,有两个相关的分析。在每个分析中,有一些不同类型的结果。
界面变得非常繁忙,我希望输出元素可折叠(maybe like this)。
是否有此类ui
文件的示例?我现在看起来像这样:
shinyUI(
fluidPage(
tabsetPanel(
tabPanel("Analysis 1",
sidebarPanel(
sliderInput("value1", "some value",
min=1, max=20, value=5, step=0.2)
),
mainPanel(
## these two elements collapse together
p(textOutput("results_1_a_text")),
plotOutput("results_1_a_graph", height = "400px"),
## these two elements collapse together
p(textOutput("results_1_b_text")),
plotOutput("results_1_b_graph", height = "400px")
)
),
tabPanel("Analysis 2",
sidebarPanel(
sliderInput("value2", "some value",
min=1, max=20, value=5, step=0.2)
),
mainPanel(
## these two elements collapse together
p(textOutput("results_2_a_text")),
plotOutput("results_2_a_graph", height = "400px"),
## these two elements collapse together
p(textOutput("results_2_b_text")),
plotOutput("results_2_b_graph", height = "400px")
)
)
)
)
)
谢谢,
最高
答案 0 :(得分:4)
查看ShinyBS。从那里采取的例子
library(shiny)
library(shinyBS)
shinyApp(
ui =
fluidPage(
sidebarLayout(
sidebarPanel(HTML("This button will open Panel 1 using updateCollapse."),
actionButton("p1Button", "Push Me!"),
selectInput("styleSelect", "Select style for Panel 1",
c("default", "primary", "danger", "warning", "info", "success"))
),
mainPanel(
bsCollapse(id = "collapseExample", open = "Panel 2",
bsCollapsePanel("Panel 1", "This is a panel with just text ",
"and has the default style. You can change the style in ",
"the sidebar.", style = "info"),
bsCollapsePanel("Panel 2", "This panel has a generic plot. ",
"and a 'success' style.", plotOutput("genericPlot"), style = "success")
)
)
)
),
server =
function(input, output, session) {
output$genericPlot <- renderPlot(plot(rnorm(100)))
observeEvent(input$p1Button, ({
updateCollapse(session, "collapseExample", open = "Panel 1")
}))
observeEvent(input$styleSelect, ({
updateCollapse(session, "collapseExample", style = list("Panel 1" = input$styleSelect))
}))
}
)