MoreWidget

MoreWidget
verbatimTextOutput(outputId)
renderPrint(expr, env=parent.frame(), quoted=FALSE, func=NULL)
ui.R
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("More Widget"),
sidebarPanel(
selectInput("dataset", "choose a dataset: ", choices=c("rock", "pressure", "cars")),
numericInput("obs", "Number of observations to view: ", 10),
helpText("Note: While the data view will show only the specified", "number of observations, the summary will stilled be based", "on the full dataset."),
submitButton("Update View")
),
mainPanel(
h4("Summary"),
verbatimTextOutput("summary"),
h4("Observations"),
tableOutput("view")
)
))
server.R
library(shiny)
library(datasets)
shinyServer(function(input, output){
datasetInput<-reactive({
switch(input$dataset, "rock"=rock, "pressure"=pressure, "cars"=cars)
})
output$summary<-renderPrint({
dataset<-datasetInput()
summary(dataset)
})
output$view<-renderTable({
head(datasetInput(), n=input$obs)
})
})