Skip to content

Instantly share code, notes, and snippets.

@withr

withr/server.R Secret

Created October 17, 2014 10:53
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 withr/d17fe7d161514fed287f to your computer and use it in GitHub Desktop.
Save withr/d17fe7d161514fed287f to your computer and use it in GitHub Desktop.
R fortunes
library(fortunes)
n <- nrow(read.fortunes())
shinyServer(function(input, output) {
update <- reactive({
if (input$action > 0){
sample(1:n, 1)
}
})
output$summary <- renderPrint({
fortune(update())
})
})
shinyUI(bootstrapPage(
tagList(
tags$head(
tags$title("Upload Data"),
tags$link(rel="stylesheet", type="text/css",href="style.css")
),
tags$body(
tags$h1("R fortunes:")
)
),
# headerPanel("R fortunes:"),
div(class='button', actionButton("action", "Next Fortune!")),
div(class='output', verbatimTextOutput("summary"))
))
div.button {
margin: 10px 20px;
}
div.output {
margin: 10px 20px;
width: auto;
}
h1 {
margin: 10px 20px;
}
pre {
font-size: 16px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment