使用conditionalPanel(或其他方法)创建临时横幅,如果用户导航,该横幅消失

时间:2014-08-11 22:33:24

标签: r shiny rstudio

我想在用户首次打开闪亮网页时创建欢迎消息。目前我拥有它,它不断在第一个tabPanel上。当用户导航然后返回该面板时,有没有办法让它消失?

fluidRow(
  column(width=12,
         tabsetPanel(type = "tabs",  id = "tabs1", 
                     tabPanel("Express Usage", wellPanel("Welcome! Please select the libraries you are interested in viewing from below and use the tabs to navigate between graphs. It is best to limit your selection to no more than 5 libraries at a time"), plotOutput("express_Plot", height=400)),
                     tabPanel("Juvenile Usage", plotOutput("juvenile_Plot", height=400)), 
                     tabPanel("test", h3(textOutput("text_test")))))
  ), 

1 个答案:

答案 0 :(得分:0)

您可以相应地为所有value设置tabPanel属性。 通过这种方式,您可以在 server.R 中通过阅读input$tabs1来确定当前选择了哪个标签,其中tabs1是您为此设置的id tabsetPanel

wellPanel替换为uiOutput元素,并根据更新UI元素 到:

  1. 当前面板。
  2. 访问小组的时间。
  3. ui.R

    library(shiny)
    shinyUI(fluidPage(
      fluidRow(
        column(width=12,
               tabsetPanel(type = "tabs",  id = "tabs1", 
                           tabPanel("Express Usage", 
                                    uiOutput("welcome"), # replace the wellPanel
                                    plotOutput("express_Plot", height=400), value="ex_usage"),
                           tabPanel("Juvenile Usage", plotOutput("juvenile_Plot", height=400), value="juv_usage"), 
                           tabPanel("test", h3(textOutput("text_test")))), value="test")
      )
    )
    )
    

    server.R

    library(shiny)
    
    shinyServer(function(input, output, session){
      visits <- reactiveValues(times = 0)
      output$welcome <- renderUI({
        if (input$tabs1 == "ex_usage") {
          isolate(visits$times <- visits$times + 1)
          if (isolate(visits$times) == 1) {
            return (wellPanel("Welcome! Please select the libraries you are interested in viewing from below and use the tabs to navigate between graphs. It is best to limit your selection to no more than 5 libraries at a time"))
          }
          else {
            return ()
          }
        }
      })
    })