我有一个简单的问题,我只想显示" text"取消选中该复选框时。但是,未显示的情节已经显示出来。我需要删除它。
shinyUI(fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data")
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
checkboxInput("click","Plot")
),
# Show a plot of the generated distribution
mainPanel(
splitLayout(plotOutput("distPlot"), h4("Just Text"))))))
library(shiny)
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
if(input$click){
# 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')
}
else (return(0))})})
答案 0 :(得分:4)
如果我理解正确,您可以将mainPanel
更改为conditionalPanel
。将mainPanel
代码替换为:
mainPanel(
conditionalPanel(condition = "input.click === true",
plotOutput("distplot")
),
conditionalPanel(condition = "input.click === false",
h4("Just text...")
)
)
现在,当您选中复选框时,文本框将消失,并且您的图表会显示出来。