add text example

This commit is contained in:
JJ Allaire
2012-07-25 08:07:36 -04:00
parent 66ddb6ce0a
commit 61bd2d356b
2 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
library(shiny)
shinyServer(function(input, output) {
datasetInput <- function() {
switch(input$dataset,
"rock" = rock,
"pressure" = pressure,
"cars" = cars)
}
output$summary <- reactiveText(function() {
dataset <- datasetInput()
summary(dataset)
})
output$view <- reactiveTable(function() {
obs <- as.integer(input$obs)
head(datasetInput(), n = obs)
})
})

19
inst/examples/text/ui.R Normal file
View File

@@ -0,0 +1,19 @@
library(shiny)
shinyUI(pageWithSidebar(
headerPanel(
h1("Shiny text")
),
sidebarPanel(
selectInput("dataset", "Choose a dataset:",
choices = c("rock", "pressure", "cars")),
numericInput("obs", "Number of observations to view:", 10)
),
mainPanel(
verbatimTextOutput("summary"),
tableOutput("view")
)
))