Skip to content

Instantly share code, notes, and snippets.

@hadley
Forked from anonymous/server.R
Created December 23, 2013 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadley/8105463 to your computer and use it in GitHub Desktop.
Save hadley/8105463 to your computer and use it in GitHub Desktop.
# 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)
})
}
)
# 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