Created
December 23, 2013 19:11
-
-
Save anonymous/8102844 to your computer and use it in GitHub Desktop.
counter demo
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
# server.R | |
library("shiny") | |
shinyServer( | |
function(input, output){ | |
output$displayCounter <- renderText({ | |
c("value of counter:", updateCounter()) | |
}) | |
updateCounter <- reactive({ | |
if (input$counter == 0) {k <- 0} | |
else {k <- input$counter-input$subcounter} | |
write(k, 'file'="counter.txt") | |
return(k) | |
}) | |
} | |
) |
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
# ui.R | |
library("shiny") | |
shinyUI( | |
pageWithSidebar( | |
headerPanel("Counter Demo with invisible sidebarPanel") | |
, | |
sidebarPanel( | |
tags$head( | |
tags$style(type='text/css' | |
# sidebarPanel appearance | |
, ".row-fluid .span4 {width: 0px; height: 0px;}" | |
, ".row-fluid .well {padding: 0px; border: 0px;}" | |
, ".row-fluid .span4 {background-color: rgb(0, 0, 0);}" | |
# button appearance | |
, ".btn {padding: 15px; font-size: 120%;}" | |
) | |
) | |
) | |
, | |
mainPanel( | |
helpText("This demo illustrates how to use an actionButton to add to and subtract from a counter") | |
, | |
actionButton("counter","Raise counter") | |
, tags$br(), tags$br() | |
, | |
actionButton("subcounter","Lower counter") | |
, tags$br(), tags$br() | |
, | |
uiOutput("displayCounter") | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment