Last active
July 28, 2021 13:12
-
-
Save aagarw30/2b46c89e686a956098e20cb90b1cf004 to your computer and use it in GitHub Desktop.
Multiple action buttons in R Shiny
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Title: Multiple Action Button Demo - An attempt to button event based navigation/actions. Powered by R, Shiny and Rstudio. | |
License: GPL-3 | |
Author: Abhinav Agrawal | |
DisplayMode: Showcase | |
Tags: action button, R, R Shiny | |
Type: Shiny |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyServer(function(input, output,session){ | |
but1 = reactiveValues(but1=FALSE) | |
but2 = reactiveValues(but2=FALSE) | |
but3 = reactiveValues(but3=FALSE) | |
observeEvent(input$buttonuno, | |
isolate({but1$but1=TRUE | |
but2$but2=FALSE | |
but3$but3=FALSE | |
})) | |
observeEvent(input$buttondos, | |
isolate({but1$but1=FALSE | |
but2$but2=TRUE | |
but3$but3=FALSE | |
})) | |
observeEvent(input$buttontres, | |
isolate({but1$but1=FALSE | |
but2$but2=FALSE | |
but3$but3=TRUE | |
})) | |
output$uno <- renderText({ | |
if(but1$but1) | |
paste("ustedes selectado button uno") ## cambiarlo esos con renderUI | |
else | |
return() | |
}) | |
output$dos <- renderText({ | |
if(but2$but2) | |
paste("ustedes selectado button dos") ## cambiarlo esos con renderUI | |
else | |
return() | |
}) | |
output$tres <- renderText({ | |
if(but3$but3) | |
paste("ustedes selectado button tres") ## cambiarlo esos con renderUI | |
else | |
return() | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# R Shiny app demo - display PDF in app as reference document | |
library(shiny) | |
# Simple shiny layout for demo sake | |
shinyUI(fluidPage( | |
sidebarLayout( | |
sidebarPanel( | |
h5("use case - button based navigation"), | |
actionButton(inputId = "buttonuno", label = "buttonuno"), | |
br(), | |
actionButton(inputId = "buttondos", label = "buttondos"), | |
br(), | |
actionButton(inputId = "buttontres", label = "buttontres") | |
), | |
mainPanel( | |
textOutput("uno"), | |
textOutput("dos"), | |
textOutput("tres") | |
) | |
)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment