mirror of
https://github.com/rstudio/shiny.git
synced 2026-02-06 20:55:24 -05:00
Simplify output API
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
library(digest)
|
||||
|
||||
text <- observable(function() {
|
||||
text <- reactive(function() {
|
||||
str <- input$input1
|
||||
if (input$addnewline)
|
||||
str <- paste(str, "\n", sep='')
|
||||
return(str)
|
||||
})
|
||||
|
||||
define.output('md5_hash', function() {
|
||||
digest(text$get.value(), algo='md5', serialize=F)
|
||||
output$md5_hash <- reactive(function() {
|
||||
digest(text(), algo='md5', serialize=F)
|
||||
})
|
||||
|
||||
output$sha1_hash <- reactive(function() {
|
||||
digest(text(), algo='sha1', serialize=F)
|
||||
})
|
||||
define.output('sha1_hash', function() {
|
||||
digest(text$get.value(), algo='sha1', serialize=F)
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
data <- observable(function() {
|
||||
data <- reactive(function() {
|
||||
# Choose a distribution function
|
||||
dist <- switch(input$dist,
|
||||
norm = rnorm,
|
||||
@@ -11,18 +11,18 @@ data <- observable(function() {
|
||||
dist(as.integer(input$n))
|
||||
})
|
||||
|
||||
define.plot('plot1', function() {
|
||||
output$plot1 <- reactivePlot(function() {
|
||||
dist <- input$dist
|
||||
n <- input$n
|
||||
|
||||
hist(data$get.value(),
|
||||
hist(data(),
|
||||
main=paste('r', dist, '(', n, ')', sep=''))
|
||||
}, width=600, height=300)
|
||||
|
||||
define.table('table1', function() {
|
||||
data.frame(x=data$get.value())
|
||||
output$table1 <- reactiveTable(function() {
|
||||
data.frame(x=data())
|
||||
})
|
||||
|
||||
define.output('summary1', function() {
|
||||
paste(capture.output(print(summary(data$get.value()))), collapse="\n")
|
||||
output$summary1 <- reactiveText(function() {
|
||||
summary(data())
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user