13.6 Examples of Shiny apps
# load the shiny package
library(shiny)
# define the user interface object with the appearance of the app
<- fluidPage(
ui numericInput(inputId = "n", label = "Sample size", value = 25),
plotOutput(outputId = "hist")
)
# define the server function with instructions to build the
# objects displayed in the ui
<- function(input, output) {
server $hist <- renderPlot({
outputhist(rnorm(input$n))
})
}
# call shinyApp() which returns the Shiny app object
shinyApp(ui = ui, server = server)