Last active
August 29, 2015 14:12
-
-
Save asudipta/88499b9e08d75a9f18d7 to your computer and use it in GitHub Desktop.
Testing how gists works
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(datasets) | |
# Define server logic required to summarize and view the selected dataset | |
shinyServer(function(input, output) { | |
# Return the requested dataset | |
datasetInput <- reactive({ | |
switch(input$dataset, | |
"rock" = rock, | |
"pressure" = pressure, | |
"cars" = cars) | |
}) | |
# Generate a summary of the dataset | |
output$summary <- renderPrint({ | |
dataset <- datasetInput() | |
summary(dataset) | |
}) | |
# Show the first "n" observations | |
output$view <- renderTable({ | |
head(datasetInput(), n = input$obs) | |
}) | |
}) |
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) | |
# Define UI for dataset viewer application | |
shinyUI(pageWithSidebar( | |
# Application title | |
headerPanel("Shiny Text"), | |
# Sidebar with controls to select a dataset and specify the number | |
# of observations to view | |
sidebarPanel( | |
selectInput("dataset", "Choose a dataset:", | |
choices = c("rock", "pressure", "cars")), | |
numericInput("obs", "Number of observations to view:", 10) | |
), | |
# Show a summary of the dataset and an HTML table with the requested | |
# number of observations | |
mainPanel( | |
verbatimTextOutput("summary"), | |
tableOutput("view") | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment