如何在SHINY中选择特定的选项卡面板 [英] How to select a specific tabPanel in Shiny

查看:30
本文介绍了如何在SHINY中选择特定的选项卡面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Simply Shop应用程序中动态选择一个特殊的选项卡面板。APP的脚本如下:

ui.r

library(shiny)
shinyUI(fluidPage(

  titlePanel("SCORE CARD DEVELOPMENT PLATFORM"),
    navbarPage("ScoreDevApp",
         tabPanel("Settings",
                  fluidRow(column(2,
                                  actionButton("goButton_service", "Load   saved parameters",width=200)
                                  )
                          )
         ),
         tabPanel("Download & Binning input data")
        )
)
)

服务器。r

library(shiny)

shinyServer(function(input, output, session) {
  #load saved parameters 
  observeEvent(input$goButton_service, {
    updateTabsetPanel(session, "ScoreDevApp", selected = "Download & Binning  input data")
 })  
})  

按下按钮"goButton_service"并选择选项卡面板"下载和装箱输入数据"

我使用了此处的示例R Shiny switch tabPanel when selectInput value changes

但是,未选择tabPanel。我将非常感谢您的帮助:-)

推荐答案

问题是您的UI中没有tabsetPanel(它应该是两个选项卡面板的父项)。当前您正在使用updateTabsetPanel,但目标是navbarPage

下面的工作解决方案。有两个问题:navbarPage需要一个id,并且服务器上有额外的空间。Rselected(在bin和input`之间)

ui.R

library(shiny)
shinyUI(fluidPage(

    titlePanel("SCORE CARD DEVELOPMENT PLATFORM"),
    navbarPage("ScoreDevApp",
               tabPanel("Settings",
                        fluidRow(column(2,
                                        actionButton("goButton_service", "Load   saved parameters",width=200)
                        )
                        )
               ),
               tabPanel("Download & Binning input data"),
               id="ScoreDevApp"
    )
)
)

server.R

库(闪亮)

shinyServer(function(input, output, session) {
    #load saved parameters 
    observeEvent(input$goButton_service, {
        updateNavbarPage(session, "ScoreDevApp", selected = "Download & Binning input data")
    })  
})  

这篇关于如何在SHINY中选择特定的选项卡面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆