Build a "Hello, world" Shiny app

Building Web Applications with Shiny in R

Kaelen Medeiros

Data Scientist

Parts of a Shiny app

library(shiny)

ui <- fluidPage()
server <- function(input, output, session) { }
shinyApp(ui = ui, server = server)
  • Load shiny
  • Create the UI with a HTML function
  • Define a custom function to create the server
  • Run the app
Building Web Applications with Shiny in R

Hello, world!!!

library(shiny)

ui <- fluidPage(
    "Hello, world!!!"
)

server <- function(input, output, 
                   session) {

}

shinyApp(ui = ui, server = server)

A blank web page that displays character string "Hello, world!!!"

Building Web Applications with Shiny in R

Ask a question (with an input!)

ui <- fluidPage(
    textInput("name", "Enter a name:"),

textOutput("q")
)
server <- function(input, output) {
output$q <- renderText({ paste("Do you prefer dogs or cats,", input$name, "?") })
}

A web app that allows users to enter a name and then asks "Do you prefer dogs or cats, name?"

Building Web Applications with Shiny in R

Let's practice!

Building Web Applications with Shiny in R

Preparing Video For Download...