Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bborgesr
Created April 4, 2017 19:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bborgesr/f2c865556af3b92e6991e1a34ced2a4a to your computer and use it in GitHub Desktop.
Save bborgesr/f2c865556af3b92e6991e1a34ced2a4a to your computer and use it in GitHub Desktop.
Demo of new `checkboxGroupInput()` and `radioButtons()` functionality in Shiny 1.0.1
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