Files
shiny/examples/03_distributions/app.R
2012-06-28 22:27:22 -07:00

28 lines
724 B
R

data <- Observable$new(function() {
# Choose a distribution function
dist <- switch(get.input('dist'),
norm = rnorm,
unif = runif,
lnorm = rlnorm,
exp = rexp,
rnorm)
# Generate n values from the distribution function
dist(max(1, get.input('n')))
})
define.plot('plot1', function() {
dist <- get.input('dist')
n <- get.input('n')
hist(data$get.value(),
main=paste('r', dist, '(', n, ')', sep=''))
}, width=600, height=300)
define.table('table1', function() {
data.frame(x=data$get.value())
})
define.output('summary1', function() {
paste(capture.output(print(summary(data$get.value()))), collapse="\n")
})