面板对齐闪亮

Panel aligned in shiny

伙计们,我使用了 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)

非常感谢各位朋友!

您不需要额外的 sidebarLayoutsidebarPanel。您可以将第二个滑块放在第一个滑块下方。 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)
    )