Created
April 4, 2017 19:51
-
-
Save bborgesr/f2c865556af3b92e6991e1a34ced2a4a to your computer and use it in GitHub Desktop.
Demo of new `checkboxGroupInput()` and `radioButtons()` functionality in Shiny 1.0.1
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
library(shiny) | |
countries <- c("Australia", "United Kingdom", "United States") | |
flags <- c( | |
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/au.svg", | |
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/gb.svg", | |
"https://cdn.rawgit.com/lipis/flag-icon-css/master/flags/4x3/us.svg" | |
) | |
ui <- fluidPage( | |
checkboxGroupInput("countries", "Countries", | |
choiceNames = mapply(countries, flags, FUN = function(country, flagUrl) { | |
tagList( | |
tags$img(src=flagUrl, width=20, height=15), | |
country | |
) | |
}, SIMPLIFY = FALSE, USE.NAMES = FALSE), | |
choiceValues = countries | |
), | |
textOutput("txt") | |
) | |
server <- function(input, output, session) { | |
output$txt <- renderText({ | |
paste("You chose", paste(input$countries, collapse = ", ")) | |
}) | |
} | |
shinyApp(ui, server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment