Shinylive Demo

A fully interactive Shiny app running entirely in your browser.

NoteLearning Objectives
  • See how Shiny apps can run without a server using Shinylive
  • Explore how reactive inputs (sliders) update outputs (plots) in real time
  • Observe the effect of sample size, mean, and standard deviation on a distribution

Client-Side Shiny App

This Shiny app runs entirely in the browser via Shinylive – no server required. Use the sliders to explore how parameters affect the normal distribution.


#| '!! shinylive warning !!': |
#|   shinylive does not work in self-contained HTML documents.
#|   Please set `embed-resources: false` in your metadata.
#| standalone: true
#| viewerHeight: 500

library(shiny)

ui <- fluidPage(
  titlePanel("Normal Distribution Explorer"),
  sidebarLayout(
    sidebarPanel(
      sliderInput("n", "Number of observations:", min = 50, max = 1000, value = 200),
      sliderInput("mean", "Mean:", min = -5, max = 5, value = 0, step = 0.5),
      sliderInput("sd", "Standard deviation:", min = 0.5, max = 5, value = 1, step = 0.5)
    ),
    mainPanel(
      plotOutput("histogram")
    )
  )
)

server <- function(input, output) {
  output$histogram <- renderPlot({
    data <- rnorm(input$n, mean = input$mean, sd = input$sd)
    hist(data, breaks = 30, col = "steelblue", border = "white",
         main = paste("n =", input$n, " mean =", input$mean, " sd =", input$sd),
         xlab = "Value")
  })
}

shinyApp(ui, server)
TipTry It Yourself
  • Set the standard deviation to 0.5 and the number of observations to 1000. How does the histogram shape compare to sd = 5?
  • Move the mean slider and watch how the entire distribution shifts along the x-axis.