Home | RStudio IDE | Shiny | Training | Projects | About | Blog |
Shiny makes it super simple for R users like you to turn analyses into interactive web applications that anyone can use. Let your users choose input parameters using friendly controls like sliders, drop-downs, and text fields. Easily incorporate any number of outputs like plots, tables, and summaries.
No HTML or JavaScript knowledge is necessary. If you have some experience with R, you're just minutes away from combining the statistical power of R with the simplicity of a web page.
Here's a basic Shiny application, consisting of less than 40 lines of code.
Try changing the number of bins and toggling the checkboxes.
shinyUI(bootstrapPage(
selectInput(inputId = "n_breaks",
label = "Number of bins in histogram (approximate):",
choices = c(10, 20, 35, 50),
selected = 20),
checkboxInput(inputId = "individual_obs",
label = strong("Show individual observations"),
value = FALSE),
checkboxInput(inputId = "density",
label = strong("Show density estimate"),
value = FALSE),
plotOutput(outputId = "main_plot", height = "300px"),
# Display this only if the density is shown
conditionalPanel(condition = "input.density == true",
sliderInput(inputId = "bw_adjust",
label = "Bandwidth adjustment:",
min = 0.2, max = 2, value = 1, step = 0.2)
)
))
shinyServer(function(input, output) {
output$main_plot <- reactivePlot(function() {
hist(faithful$eruptions,
probability = TRUE,
breaks = as.numeric(input$n_breaks),
xlab = "Duration (minutes)",
main = "Geyser eruption duration")
if (input$individual_obs) {
rug(faithful$eruptions)
}
if (input$density) {
dens <- density(faithful$eruptions,
adjust = input$bw_adjust)
lines(dens, col = "blue")
}
})
})
Please see our tutorial to learn more about writing Shiny apps.
First, install the shiny package by entering these two commands at your R console:
options(repos=c(RStudio='rstudio.org/_packages', getOption('repos')))
install.packages('shiny')
Then take a look at our tutorial, which will take you on a step-by-step tour through Shiny. (There's also documentation in the R package, but we highly recommend you go through most of the tutorial before diving into the function-level documentation.)
The Shiny package is free and open source, and is designed primarily to run Shiny applications locally. To share Shiny applications with others, you can send them your application source as a GitHub gist, R package, or zip file (see details). We think this is an effective and powerful model of application distribution that will work well for a lot of people.
We're also working on a Shiny server that is designed to provide enterprise-grade application hosting, which we'll offer as a subscription-based hosting service and/or commercial software package. If you’d like to help us beta test Shiny server, please register now.
Join shiny-discuss and let us know if you have any questions/comments, or just want to show off your latest Shiny app!