mirror of
https://github.com/rstudio/shiny.git
synced 2026-01-30 17:28:32 -05:00
26 lines
577 B
R
26 lines
577 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({
|
|
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)
|
|
})
|
|
})
|