mirror of
https://github.com/rstudio/shiny.git
synced 2026-02-08 21:55:02 -05:00
move doc and examples to inst directory
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
library(shiny)
|
||||
|
||||
server(function(input, output) {
|
||||
output$valUpper <- reactive(function() {
|
||||
toupper(input$val)
|
||||
})
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
library(shiny)
|
||||
|
||||
shinyUI(
|
||||
pageWithSidebar(
|
||||
headerPanel(
|
||||
h1("Example 1: All Caps")
|
||||
),
|
||||
|
||||
sidebarPanel(
|
||||
textInput("val", "Input:", value = "Hello, World!")
|
||||
),
|
||||
|
||||
mainPanel(
|
||||
p("You said: ", textOutput("valUpper"))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
library(shiny)
|
||||
library(digest)
|
||||
|
||||
server(function(input, output) {
|
||||
text <- reactive(function() {
|
||||
str <- input$input1
|
||||
if (input$addnewline)
|
||||
str <- paste(str, "\n", sep='')
|
||||
return(str)
|
||||
})
|
||||
|
||||
output$md5_hash <- reactive(function() {
|
||||
digest(text(), algo='md5', serialize=F)
|
||||
})
|
||||
|
||||
output$sha1_hash <- reactive(function() {
|
||||
digest(text(), algo='sha1', serialize=F)
|
||||
})
|
||||
})
|
||||
@@ -1,20 +0,0 @@
|
||||
library(shiny)
|
||||
|
||||
shinyUI(
|
||||
pageWithSidebar(
|
||||
|
||||
headerPanel(
|
||||
h1("Example 2: Computing Hashes")
|
||||
),
|
||||
|
||||
sidebarPanel(
|
||||
textInput("input1", "Input:", value="Hello, world!"),
|
||||
checkboxInput("addnewline", "Append newline", TRUE)
|
||||
),
|
||||
|
||||
mainPanel(
|
||||
p("MD5: ", textOutput("md5_hash")),
|
||||
p("SHA-1: ", textOutput("sha1_hash"))
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -1,39 +0,0 @@
|
||||
library(shiny)
|
||||
|
||||
server(function(input, output) {
|
||||
|
||||
data <- reactive(function() {
|
||||
|
||||
# If the Animate checkbox is checked, then we want to re-calculate this
|
||||
# reactive function 1 second from now
|
||||
if (input$animate)
|
||||
invalidateLater(1000)
|
||||
|
||||
# Choose a distribution function
|
||||
dist <- switch(input$dist,
|
||||
norm = rnorm,
|
||||
unif = runif,
|
||||
lnorm = rlnorm,
|
||||
exp = rexp,
|
||||
rnorm)
|
||||
|
||||
# Generate n values from the distribution function
|
||||
dist(as.integer(input$n))
|
||||
})
|
||||
|
||||
output$plot1 <- reactivePlot(function() {
|
||||
dist <- input$dist
|
||||
n <- input$n
|
||||
|
||||
hist(data(),
|
||||
main=paste('r', dist, '(', n, ')', sep=''))
|
||||
})
|
||||
|
||||
output$table1 <- reactiveTable(function() {
|
||||
data.frame(x=data())
|
||||
})
|
||||
|
||||
output$summary1 <- reactiveText(function() {
|
||||
summary(data())
|
||||
})
|
||||
})
|
||||
@@ -1,42 +0,0 @@
|
||||
|
||||
|
||||
library(shiny)
|
||||
|
||||
shinyUI(
|
||||
pageWithSidebar(
|
||||
|
||||
headerPanel(
|
||||
h1("Example 3: Distributions"),
|
||||
p("You really need to check out these distributions."),
|
||||
HTML("No, <b>really</b> you should check these out!")
|
||||
),
|
||||
|
||||
sidebarPanel(
|
||||
selectListInput("dist", "Distibution type:",
|
||||
list(norm = "Normal",
|
||||
unif = "Uniform",
|
||||
lnorm = "Log-normal",
|
||||
exp = "Exponential")),
|
||||
|
||||
helpText("You can select any distribution which you'd like to"),
|
||||
|
||||
numericInput("n",
|
||||
"Number of observations:",
|
||||
min = 0,
|
||||
max = 10000,
|
||||
value = 500),
|
||||
|
||||
checkboxInput("animate", "Animate"),
|
||||
|
||||
submitButton()
|
||||
),
|
||||
|
||||
mainPanel(
|
||||
tabsetPanel(
|
||||
tabPanel("Plot", plotOutput("plot1")),
|
||||
tabPanel("Summary", verbatimTextOutput("summary1")),
|
||||
tabPanel("Table", tableOutput("table1"))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user