Insert a selection box with options "Choice A" and "Choice B". Insert an actionbutton. When the button is pressed, display a warning modal if "Choice A" is selected. If "Choice A" is selected, display a text output of "Hello"
Drop files here
or click to upload
library(shiny)
ui <- fluidPage(
selectInput("choice", "Make a choice:",
choices = c("Choice A", "Choice B")),
actionButton("show", "Show"),
textOutput("text")
)
server <- function(input, output, session) {
observeEvent(input$show, {
if (input$choice == "Choice A") {
showModal(modalDialog(
title = "Warning",
"You selected Choice A!",
easyClose = TRUE
))
}
})
output$text <- renderText({
if (input$choice == "Choice A") {
"Hello"
}
})
}
shinyApp(ui = ui, server = server)
Hi! I can help you with any questions about Shiny and R. What would you like to know?