Created
October 12, 2013 06:16
-
-
Save xiaodaigh/6946423 to your computer and use it in GitHub Desktop.
Shiny R - Re-initialise reactive values
This file contains 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){ | |
reval <- reactiveValues(a= 1,b=2,dummy= rnorm(1)) | |
observe({ | |
if(input$hello == 0) return() | |
random.number <- rnorm(1) | |
reval$dummy <- random.number | |
b <- reval$b | |
reval <<- reactiveValues(a = 1,b = b + 1,dummy=random.number) | |
}) | |
output$a <- renderUI({ | |
reval$dummy | |
HTML(reval$b) | |
}) | |
}) |
This file contains 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) | |
shinyUI(basicPage( | |
actionButton("hello","Increase Reactive Value"), | |
htmlOutput("a"), | |
HTML('<script src="https://gist.github.com/xiaodaigh/6946423.js"></script>') | |
) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment