Skip to content

Instantly share code, notes, and snippets.

@jknowles
Created January 8, 2013 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jknowles/4484868 to your computer and use it in GitHub Desktop.
Save jknowles/4484868 to your computer and use it in GitHub Desktop.
Draw a normal distribution with a given number of observations. Demonstrate what sample sizes and approximations can mean.
library(shiny)
shinyServer(function(input,output){
output$distPlot<-reactivePlot(function(){
dist<-rnorm(input$obs)
p<-qplot(dist,binwidth=0.1)+geom_vline(xintercept=mean(dist))+theme_dpi()
p<-p+coord_cartesian(xlim=c(-4,4))+geom_vline(xintercept=median(dist),color=I("red"))
print(p)
})
})
library(shiny)
library(ggplot2)
library(eeptools)
shinyUI(pageWithSidebar(
# Title
headerPanel("Normality"),
sidebarPanel(
sliderInput("obs","Number of observations:",
min=0,max=1000,value=100)
),
# GGPLOT
mainPanel(
plotOutput("distPlot")
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment