使侧边栏面板和主面板的宽度加起来也达到12。并移除嵌套
mainPanel(mainPanel())
你有。
ui <- fluidPage(
# Application title
titlePanel(
span(
span("Stackoverflow example app"),
span(tags$h4(actionLink("contact", "Contact us")),
style = "position:absolute;right:2em;")
),
windowTitle = "Stackoverflow example app"
),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
width = 2,
sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30)
),
mainPanel(
width = 10,
fluidRow(
column(width = 6, offset = 0, wellPanel(plotOutput("distPlot"))),
column(width = 6, offset = 0, wellPanel("Panel 2"))
),
fluidRow(
column(6, offset = 0, wellPanel("Panel 3")),
column(6, offset = 0, wellPanel("Panel 4"))
)
)
)
)
# Define server logic required to draw a histogram
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',
xlab = 'Waiting time to next eruption (in mins)',
main = 'Histogram of waiting times')
})
}
# Run the application
shinyApp(ui = ui, server = server)