Skip to content

Instantly share code, notes, and snippets.

@renkun-ken
Created January 24, 2016 16:03
Show Gist options
  • Save renkun-ken/3b2a939e363e8872c925 to your computer and use it in GitHub Desktop.
Save renkun-ken/3b2a939e363e8872c925 to your computer and use it in GitHub Desktop.
iris-formattable
library(shiny)
library(formattable)
data <- iris
species <- levels(data$Species)
ui <- shinyUI(fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarPanel(checkboxGroupInput("species", label = "species", choices = species,
selected = species),
checkboxGroupInput("columns", "columns", choices = colnames(data),
selected = colnames(data))),
mainPanel(formattableOutput("formattable_test"))
))
server <- shinyServer(function(input, output) {
output$formattable_test <- renderFormattable({
formattable(data[data$Species %in% input$species, input$columns],
list(Sepal.Length = color_tile("white", "lightpink"),
Sepal.Width = color_tile("white", "lightgreen"),
Petal.Length = color_tile("white", "lightpink"),
Petal.Width = color_tile("white", "lightgreen")))
})
})
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment