Created
August 14, 2013 20:57
-
-
Save ijlyttle/6235528 to your computer and use it in GitHub Desktop.
coding all elements by hand
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) | |
items <- c("seed") | |
shinyServer(function(input, output) { | |
add_item_a <- reactive({ | |
# register button | |
n_click <- input$item_add_a_go | |
if (n_click > 0){ | |
new_item <- isolate(input$item_add_a) | |
items <<- c(items, new_item) | |
} | |
return() | |
}) | |
add_item_b <- reactive({ | |
# register button | |
n_click <- input$item_add_b_go | |
if (n_click > 0){ | |
new_item <- isolate(input$item_add_b) | |
items <<- c(items, new_item) | |
} | |
return() | |
}) | |
get_items <- reactive({ | |
# register "adders" | |
add_item_a() | |
add_item_b() | |
return(items) | |
}) | |
output$show_items <- renderPrint(get_items()) | |
}) |
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(pageWithSidebar( | |
# Application title | |
headerPanel("Test of reactivity"), | |
sidebarPanel( | |
# add item & go button | |
textInput(inputId="item_add_a", label="Add an item here", value=""), | |
actionButton(inputId="item_add_a_go", label="Go!"), | |
# add item | |
textInput(inputId="item_add_b", label="Or, add an item here", value=""), | |
actionButton(inputId="item_add_b_go", label="Go!") | |
), | |
mainPanel( | |
verbatimTextOutput(outputId="show_items") | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment