伙计们,我用shiny提供的可执行代码添加了另一个面板。我如何将第二个面板放在第一个面板下面?可以吗?非常感谢各位朋友!
library(shiny)
ui <- fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 20,
value = 30),
),
mainPanel(
plotOutput("distPlot")
)
)
))
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
# Run the application
shinyApp(ui = ui, server = server)
非常感谢各位朋友
你不需要额外的 sidebarLayout
和 sidebarPanel
. 你可以把第二个滑块放在第一个滑块的下面。tags$hr()
这里是为了在视觉上将它们分开,如果你需要的话。
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
tags$hr(),
sliderInput("bins",
"Number of bins:",
min = 1,
max = 20,
value = 30)
)