Files
shiny/inst/examples/07_widgets/server.R
2012-07-25 14:42:50 -07:00

27 lines
640 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 <- reactiveText(function() {
dataset <- datasetInput()
summary(dataset)
})
# Show the first "n" observations
output$view <- reactiveTable(function() {
obs <- as.integer(input$obs)
head(datasetInput(), n = obs)
})
})