r - 在R闪亮中隐藏标签面板
问题描述
伙计们。我有一个关于如何在 R Shiny 中隐藏 tabpanel 的问题。我在这里阅读了参考资料。 https://shiny.rstudio.com/reference/shiny/1.0.5/showTab.html
然后,我根据这个参考修改了我的代码,但是没有用。这是我的代码的一部分:
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
conditionalPanel(
condition = "input.tabselected == 1",
....
actionButton("hideTab","Hide Tab"),
actionButton("showTab","Show Tab")
),
mainPanel(
tabsetPanel(type = "tabs",
tabPanel(title = "D",
value=1),
tabPanel(title = "S",
value=3),
tabPanel(title = "Y",
value=2),
id = "tabselected")
)
...
server <- function(input, output) {
hideTab(inputId = "tabselected", target = "Y")
})
}
与条件面板有什么关系吗?还是可能有其他原因?谢谢你。
解决方案
value
提供给 hideTab 是错误的:
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
conditionalPanel(
condition = "input.tabselected == 1",
actionButton("hideTab","Hide Tab"),
actionButton("showTab","Show Tab")
)
),
mainPanel(
tabsetPanel(type = "tabs",
tabPanel(title = "D",
value=1),
tabPanel(title = "S",
value=3),
tabPanel(title = "Y",
value=2),
id = "tabselected")
)
)
)
server <- function(input, output) {
observeEvent(input$hideTab, {
hideTab(inputId = "tabselected", target = "2")
})
}
shinyApp(ui = ui, server = server)
推荐阅读
- django-templates - Django在模板中连接变量
- css - 奇怪的 CSS 行为相对 div 嵌套在 div 中
- logstash - 无法将 csv 特定日期格式解析为 logstash 中的日期
- javascript - 使用 AJAX 在单个产品页面中将产品添加到购物车后获取产品数据
- excel - 在 Excel 工作表中可视化组合
- node.js - 通过 NodeJS 客户端接收所有 SQS 消息
- python - Pandas 根据另一列的值列表查找一列中的值
- c# - 如何使 Vector2 偏移点始终相对于自上而下射击游戏中变换的旋转?
- ip - 如何找到我的位置公共 IP 地址?
- java - Jackson/Gson 从 Json 获取指定的密钥 - Java