Conditioning from insertUI

Hello! I have a toy example at the moment in which I only want the plot to appear if a certain Letter is selected. However, the selectInput is in an insertUI section in the server. At the moment, the plot always prints. Here is the code:

ui <- fluidPage(
  actionButton("add", "Add UI"),

  conditionalPanel(
  condition = "input$txt11=='F'",
  plotOutput("plot1")  
)

  
)

server <- function(input, output, session) {
  observeEvent(input$add, {
  a1 <- LETTERS[1:10]
  b1 <- letters[1:10]
    insertUI(
      selector = "#add",
      where = "afterEnd",
      ui = ({
      selectInput(paste0("txt1", input$add),choices=sample(a1),
                     label="Select a letter")

  
		     
      		     }),
    insertUI(
      selector = "#add",
      where = "afterEnd",
      ui = ({
		     
      selectInput(paste0("txt2", input$add),choices=sample(b1),
                     label="Select a lower case letter")
	})
	)

    )
    output$plot1 <- ({
    print(input$txt11)
    renderPlot(hist(rnorm(500)))
    })
 
  })
}

shinyApp(ui, server)

Any suggestions much appreciated.
Thanks,
Erin

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.