mirror of
https://github.com/rstudio/shiny.git
synced 2026-02-06 20:55:24 -05:00
Simplify API
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
library(digest)
|
||||
|
||||
input <- Observable$new(function() {
|
||||
str <- get.input('input1')
|
||||
if (get.input('addnewline'))
|
||||
text <- observable(function() {
|
||||
str <- input$input1
|
||||
if (input$addnewline)
|
||||
str <- paste(str, "\n", sep='')
|
||||
return(str)
|
||||
})
|
||||
|
||||
define.output('md5_hash', function() {
|
||||
digest(input$get.value(), algo='md5', serialize=F)
|
||||
digest(text$get.value(), algo='md5', serialize=F)
|
||||
})
|
||||
define.output('sha1_hash', function() {
|
||||
digest(input$get.value(), algo='sha1', serialize=F)
|
||||
digest(text$get.value(), algo='sha1', serialize=F)
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
data <- Observable$new(function() {
|
||||
data <- observable(function() {
|
||||
# Choose a distribution function
|
||||
dist <- switch(get.input('dist'),
|
||||
dist <- switch(input$dist,
|
||||
norm = rnorm,
|
||||
unif = runif,
|
||||
lnorm = rlnorm,
|
||||
@@ -8,12 +8,12 @@ data <- Observable$new(function() {
|
||||
rnorm)
|
||||
|
||||
# Generate n values from the distribution function
|
||||
dist(as.integer(get.input('n')))
|
||||
dist(as.integer(input$n))
|
||||
})
|
||||
|
||||
define.plot('plot1', function() {
|
||||
dist <- get.input('dist')
|
||||
n <- get.input('n')
|
||||
dist <- input$dist
|
||||
n <- input$n
|
||||
|
||||
hist(data$get.value(),
|
||||
main=paste('r', dist, '(', n, ')', sep=''))
|
||||
@@ -25,4 +25,4 @@ define.table('table1', function() {
|
||||
|
||||
define.output('summary1', function() {
|
||||
paste(capture.output(print(summary(data$get.value()))), collapse="\n")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user