inst/examples/02_text/server.R

library(shiny)
library(datasets)

# Define server logic required to summarize and view the selected
# dataset
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)
  })
}
sheikhbarabas/shiny documentation built on May 29, 2019, 9:22 p.m.