【问题标题】:Panel aligned in shiny面板以闪亮对齐
【发布时间】:2020-04-26 02:13:58
【问题描述】:

伙计们,我采用了闪亮提供的可执行代码并添加了另一个面板。如何将第二个面板留在第一个面板下?可能吗 ???非常感谢!

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)

非常感谢各位朋友!

【问题讨论】:

    标签: r shiny panel


    【解决方案1】:

    您不需要额外的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)
        )
    

    【讨论】:

    • 感谢 Novica 的回答。还有一件事,例如在标签$ hr() 下方插入文本。比如我想说的是:“这是第二个版本)
    • @Jose 是的,您可以这样做。在此处查看标签词汇表:shiny.rstudio.com/articles/tag-glossary.html
    猜你喜欢
    • 1970-01-01
    • 2022-06-21
    • 2017-04-29
    • 2015-04-29
    • 2014-06-30
    • 2015-04-26
    • 1970-01-01
    • 2018-08-05
    • 2016-12-20
    相关资源
    最近更新 更多