-
-
Save jcheng5/9494813 to your computer and use it in GitHub Desktop.
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
Title: Basic DataTable | |
Author: Jeff Allen <jeff@rstudio.com> | |
AuthorUrl: http://www.rstudio.com/ | |
License: MIT | |
DisplayMode: Showcase | |
Tags: mtcars selectinput datatables | |
Type: Shiny |
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) | |
# Load the ggplot2 package which provides | |
# the 'mpg' dataset. | |
library(ggplot2) | |
# Define a server for the Shiny app | |
shinyServer(function(input, output) { | |
# Filter data based on selections | |
output$table <- renderDataTable({ | |
data <- mpg | |
if (input$man != "All"){ | |
data <- data[data$manufacturer == input$man,] | |
} | |
if (input$cyl != "All"){ | |
data <- data[data$cyl == input$cyl,] | |
} | |
if (input$trans != "All"){ | |
data <- data[data$trans == input$trans,] | |
} | |
data | |
}) | |
}) |
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) | |
# Load the ggplot2 package which provides | |
# the 'mpg' dataset. | |
library(ggplot2) | |
# Define the overall UI | |
shinyUI( | |
fluidPage( | |
titlePanel("Basic DataTable"), | |
# Create a new Row in the UI for selectInputs | |
fluidRow( | |
column(4, | |
selectInput("man", | |
"Manufacturer:", | |
c("All", | |
unique(as.character(mpg$manufacturer)))) | |
), | |
column(4, | |
selectInput("trans", | |
"Transmission:", | |
c("All", | |
unique(as.character(mpg$trans)))) | |
), | |
column(4, | |
selectInput("cyl", | |
"Cylinders:", | |
c("All", | |
unique(as.character(mpg$cyl)))) | |
) | |
), | |
# Create a new row for the table. | |
fluidRow( | |
dataTableOutput(outputId="table") | |
) | |
) | |
) |
@arunsoni: Those are options to the DataTables js library (https://datatables.net/) that can be passed using options
argument to renderDataTable
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have two questions on this app:
Thank you