library(shiny)

shinyServer(function(input, output) {
    output$observations <- renderText({
        set.seed(input$seed)
        X <- rbinom(n=input$n,size=1,prob=input$p)
        paste("Observations",
              paste(X,collapse=", "),
              paste("\\hat{p}=",sum(X)/input$n,sep=""),
              sep="\n")
    })
    output$likelihood <-   renderPlot({
        set.seed(input$seed)
        X <- rbinom(n=input$n,size=1,prob=input$p)

        p <- seq(0,1,by=0.005)
        plot(p,p^sum(X)*(1-p)^(input$n-sum(X)),xlab="p",ylab="L(p)",main="Likelihood function",type="l")
        lines(rep(sum(X)/input$n,2),c(0,1000),col="red")
    })
})