Files
shiny/inst/examples/02_text/server.R
2012-07-27 09:34:03 -07:00

26 lines
614 B
R

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(function() {
switch(input$dataset,
"rock" = rock,
"pressure" = pressure,
"cars" = cars)
})
# Generate a summary of the dataset
output$summary <- reactivePrint(function() {
dataset <- datasetInput()
summary(dataset)
})
# Show the first "n" observations
output$view <- reactiveTable(function() {
head(datasetInput(), n = input$obs)
})
})