[英]How to change sidebarPanel for every tabPanel in the Main Panel
[英]Shiny: How to embed a sidebarPanel inside tabPanel?
我試圖在一個特定的選項卡中有一個selecInput面板,我不知道該怎么做。 在函數tabPanel()內部,我試圖在函數plotOutput()之后包含sidebarPanel(),但是sidebarPanel不再在側面,而是在左側並重疊直方圖。 是否有辦法在該特定標簽中正確嵌入該側面板或將該側面板放在圖表的右側? 謝謝,下面是我使用的代碼:
mainPanel(
tabsetPanel(
tabPanel("Histogram",plotOutput("histogram")),
tabPanel("Scatter",plotOutput("scatter"),
sidebarPanel(
selectInput("xaxis", label = "x axis",
choices = detectors, selected = detectors[1],width='200px',selectize=FALSE),
selectInput("yaxis", label = "y axis",
choices = detectors, selected = detectors[2],width='200px',selectize=FALSE),
selectInput("population1", label = "Population 1",
choices = files, selected = files[1],width='200px',selectize=FALSE),
selectInput("population2", label = "Population 2",
choices = files, selected = files[1],width='200px',selectize=FALSE),
selectInput("population3", label = "Population 3",
choices = files, selected = files[1],width='200px',selectize=FALSE)
)
),
tabPanel("Table", DT::dataTableOutput("table"))
)
)
你的概念是正確的,但代碼的放置是錯誤的。 通過以下代碼進行解釋。
library(shiny)
ui <- fluidPage(
titlePanel("Old Faithful Geyser Data"),
tabsetPanel(
tabPanel("Tab 1", h1("First tab") ),
tabPanel("Tab2",
sidebarLayout(
sidebarPanel(width = 3, sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
mainPanel(
plotOutput("distPlot")
)
)
)
)
)
server <- function(input, output) {
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
shinyApp(ui = ui, server = server)*
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.