条件面板未显示
ConditionalPannels not showing
我在使用条件面板时遇到一个奇怪的问题。
我有类似的东西
shinyUI(bootstrapPage(
selectInput(inputId = "graphT",
label = "Type of Graph :",
choices = c("x","y"),
selected = "x"),
conditionalPanel(
condition = "input.graphT == 'x'",
plotOutput(outputId = "plot1")),
conditionalPanel(
condition = "input.graphT == 'y'",
splitLayout(
cellWidths = c("50%", "50%"),
plotOutput(outputId = "plot1"),
plotOutput(outputId = "plot2")
))
))
如果我删除其中一个条件面板,另一个会在我 select 正确选项时呈现。但是,如果我让两个条件面板都没有显示,我就不会收到任何错误或消息,就像我没有发送任何输入一样。给出了什么?
问题是您有两个具有相同 ID plot1
的输出。如果您将此块中的 outputId 更改为 plot3
conditionalPanel(
condition = "input.graphT == 'x'",
plotOutput(outputId = "plot1")),
并在服务器端渲染第三个图,它会起作用。
示例:
library(shiny)
ui <- shinyUI(bootstrapPage(
selectInput(inputId = "graphT",
label = "Type of Graph :",
choices = c("x","y"),
selected = "x"),
conditionalPanel(
condition = "input.graphT == 'x'",
plotOutput(outputId = "plot3")),
conditionalPanel(
condition = "input.graphT == 'y'",
splitLayout(
cellWidths = c("50%", "50%"),
plotOutput(outputId = "plot1"),
plotOutput(outputId = "plot2")
))
))
server <- function(input, output) {
output$plot1 <- renderPlot({
plot(1)
})
output$plot2 <- renderPlot({
plot(1:10)
})
output$plot3 <- renderPlot({
plot(1:100)
})
}
shinyApp(ui, server)
我在使用条件面板时遇到一个奇怪的问题。
我有类似的东西
shinyUI(bootstrapPage(
selectInput(inputId = "graphT",
label = "Type of Graph :",
choices = c("x","y"),
selected = "x"),
conditionalPanel(
condition = "input.graphT == 'x'",
plotOutput(outputId = "plot1")),
conditionalPanel(
condition = "input.graphT == 'y'",
splitLayout(
cellWidths = c("50%", "50%"),
plotOutput(outputId = "plot1"),
plotOutput(outputId = "plot2")
))
))
如果我删除其中一个条件面板,另一个会在我 select 正确选项时呈现。但是,如果我让两个条件面板都没有显示,我就不会收到任何错误或消息,就像我没有发送任何输入一样。给出了什么?
问题是您有两个具有相同 ID plot1
的输出。如果您将此块中的 outputId 更改为 plot3
conditionalPanel(
condition = "input.graphT == 'x'",
plotOutput(outputId = "plot1")),
并在服务器端渲染第三个图,它会起作用。
示例:
library(shiny)
ui <- shinyUI(bootstrapPage(
selectInput(inputId = "graphT",
label = "Type of Graph :",
choices = c("x","y"),
selected = "x"),
conditionalPanel(
condition = "input.graphT == 'x'",
plotOutput(outputId = "plot3")),
conditionalPanel(
condition = "input.graphT == 'y'",
splitLayout(
cellWidths = c("50%", "50%"),
plotOutput(outputId = "plot1"),
plotOutput(outputId = "plot2")
))
))
server <- function(input, output) {
output$plot1 <- renderPlot({
plot(1)
})
output$plot2 <- renderPlot({
plot(1:10)
})
output$plot3 <- renderPlot({
plot(1:100)
})
}
shinyApp(ui, server)