Created
August 11, 2014 12:47
-
-
Save Su-Shee/2f577fec410b847a1fd2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) { | |
| cute_level <- c("cute", "cuter", "cutest", "cutestest") | |
| output$catpic <- renderImage({ | |
| catpic <- switch( input$kitty, | |
| "cute" = "./catpics/fuck-this-throw-down.gif", | |
| "cuter" = "./catpics/kitty-versus-printer.gif", | |
| "cutest" = "./catpics/buersten.gif", | |
| "cutestest" = "./catpics/sleepingkitty.gif" | |
| ) | |
| list(src = catpic, | |
| alt = paste("super catpic")) | |
| }, deleteFile = FALSE) | |
| output$kittySelection <- renderUI( { list( | |
| selectInput("kitty", "choose your kitteh:", cute_level, selected = 'cute'), | |
| textInput("username", "choose your username:") | |
| ) | |
| }) | |
| output$caption <- renderText( { | |
| paste("here ", input$username, " have your kitteh!") | |
| } ) | |
| # ui.R | |
| library(shiny) | |
| shinyUI( pageWithSidebar( | |
| headerPanel("want a kitty served with shiny?"), | |
| sidebarPanel( | |
| uiOutput("kittySelection") | |
| ), | |
| mainPanel( | |
| h3( textOutput("caption") ), | |
| div( imageOutput("catpic") ) | |
| ) | |
| )) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment