【问题标题】:Clear mainPanel Area in Shiny to display something else在 Shiny 中清除 mainPanel 区域以显示其他内容
【发布时间】:2015-08-28 16:05:42
【问题描述】:

我在 Shiny 中做了一个小程序,分为 5 个部分(侧边栏中的 5 个选项卡)。 但是,当我显示第一个图时,在我显示第二个图之后,第二个在第一个之下。

我想擦除面板以将新绘图正确放置在页面中。 这实际上是我在主面板中的内容。

如果我点击按钮 B1(有条件的),第一个小程序就会出现。但是,如果我想输出 cPlot1,它会出现在 gPlotsX 之后。

  conditionalPanel(
condition = "input.B1",
column(6,
plotOutput("gPlot1", click = "plot_clickA1"),
verbatimTextOutput("infoA1"),
plotOutput("gPlot3", click = "plot_clickA3"),
verbatimTextOutput("infoA3")),


column(6,
plotOutput("gPlot2", click = "plot_clickA2"),
verbatimTextOutput("infoA2"),
plotOutput("gPlot4", click = "plot_clickA4"),
verbatimTextOutput("infoA4"))),

plotOutput("cPlot1",width = "100%", height = "800px"),

如果我想显示第二部分,如何删除第一部分?

非常感谢!

【问题讨论】:

    标签: r shiny rstudio


    【解决方案1】:

    我不确定我是否正确理解了您的问题。这就是我想象您的问题的方式,希望对您有所帮助-如果没有,请提供最小的可重现示例:)

    library(shiny)
    
    ui <- shinyUI(fluidPage(
      sidebarLayout(
        sidebarPanel(
          tabsetPanel(
            tabPanel(title = "Panel 1",
                     br(),
                     h4("some content"),
                     checkboxInput(inputId = "B1", label = "Button 1", value = FALSE)
            ),
            tabPanel(title = "Panel 2",
                     br(),
                     h4("some content"),
                     checkboxInput(inputId = "B2", label = "Button 2", value = FALSE)
            )
          )
        ),
        mainPanel(
          conditionalPanel(condition = "input.B1", 
                           h4("some content"),
                           h1("Button1 is active")
          ),
          conditionalPanel(condition = "input.B2", 
                           h4("another content"),
                           h1("Button2 is active")
          )
        )
      )
    ))
    
    server <- shinyServer(function(input,output, session) {
    
      observe({ 
        # if the first button is checked - uncheck the second button
        if (input$B1) updateCheckboxInput(session, inputId = "B2", value = FALSE)
      })
    
      observe({ 
        # if the second button is checked - uncheck the first button
        if (input$B2) updateCheckboxInput(session, inputId = "B1", value = FALSE)
      })
    
    })
    
    shinyApp(ui = ui, server = server)
    

    【讨论】:

    • 感谢您的帮助,我有一个错误:ERROR: [on_request_read] connection reset by peer 我想要的只是清除所有主面板你把新的情节事实上,如果我启动选项来添加一个新情节(情节 2),他低于但没有高于。 image.noelshack.com/fichiers/2015/35/1440797854-c1.png 如您所见,第二张图位于第一张图下方。 (左)我只想要图表(右)。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-10
    • 2022-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-08
    相关资源
    最近更新 更多