Skip to content

Instantly share code, notes, and snippets.

@Su-Shee
Created August 11, 2014 12:47
Show Gist options
  • Select an option

  • Save Su-Shee/2f577fec410b847a1fd2 to your computer and use it in GitHub Desktop.

Select an option

Save Su-Shee/2f577fec410b847a1fd2 to your computer and use it in GitHub Desktop.
# 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