Created
January 24, 2016 16:03
-
-
Save renkun-ken/3b2a939e363e8872c925 to your computer and use it in GitHub Desktop.
iris-formattable
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) | |
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