简体   繁体   中英

Creating a tab after an action button has been triggered in shiny

I'm trying to generate a tab panel after a user has pressed an action button in a Rmarkdown document that's using Shiny.

Here's a minimal viable example of what I have so far (not producing the desired results):

 --- title: "Test Doc" output: html_document runtime: shiny --- ```{r, echo = FALSE, results="hide", message=FALSE, warning=FALSE} library(shiny) library(rmarkdown) ``` ```{r, echo = FALSE, cache=FALSE} sidebarPanel( actionButton("testButton", label="Test!", icon=icon("search")) ) ``` ```{r, echo = FALSE, cache=FALSE} tab_test_1<-eventReactive(input$testButton, { output$tab_test<-renderUI({ tabsetPanel(tabPanel("Plot")) }) }) uiOutput("tab_test") ``` 

Try with

```{r, echo = FALSE, cache=FALSE}
output$tab_test<-renderUI({
    req(input$testButton);
    tabsetPanel(tabPanel("Plot"))
  })
uiOutput("tab_test")
```

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM