mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-29 03:00:45 -04:00
add text example
This commit is contained in:
21
inst/examples/text/server.R
Normal file
21
inst/examples/text/server.R
Normal 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
19
inst/examples/text/ui.R
Normal 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")
|
||||
)
|
||||
))
|
||||
Reference in New Issue
Block a user