如何删除未显示的图形/文字的预订区域或闪亮的情节?

时间:2016-01-23 01:00:55

标签: r plot shiny

我有一个简单的问题,我只想显示" text"取消选中该复选框时。但是,未显示的情节已经显示出来。我需要删除它。

enter image description here enter image description here      库(有光泽)

   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))})})

1 个答案:

答案 0 :(得分:4)

如果我理解正确,您可以将mainPanel更改为conditionalPanel。将mainPanel代码替换为:

mainPanel(
  conditionalPanel(condition = "input.click === true",
                   plotOutput("distplot")
  ),
  conditionalPanel(condition = "input.click === false",
                   h4("Just text...")
  )
)

现在,当您选中复选框时,文本框将消失,并且您的图表会显示出来。