I need to select a tab from a tabset
in R Markdown document (with Shiny runtime).
I followed the example in How to select a specific tabPanel in Shiny, and tried to adapt it to R Markdown. I added id
s to the tabset / tab, and used them in the updateTabsetPanel()
call, but it doesn't seem to work. (I used the names that pop-up when inspecting the individual HTML elements in the resulting dashboard.)
How can I select the "Chart3" tab from the tabset
by clicking the button?
EDIT: I need to be able to select a specific tab programmatically (e.g. via observeEvent()
call), not just on start-up.
---
title: "Tabset Column"
output: flexdashboard::flex_dashboard
runtime: shiny
---
Column
-------------------------------------
### Chart 1
```{r}
actionButton("switch_tab", "Switch tab", width=200)
```
Column {#mytabset .tabset}
-------------------------------------
### Chart 2
```{r}
```
### Chart 3 {#mytab}
```{r}
observeEvent(input$switch_tab, {
updateTabsetPanel(session, inputId = "section-mytabset", selected = "#section-mytab")
})
```