Exercise

Simple text

Every Shiny app has a UI (User Interface) portion and a server portion. The UI is where the visual elements are placed—it controls the layout and appearance of your app. The server is where the logic of the app is implemented—where calculations are performed, plots are generates, and all instructions are given to the app.

The following is a minimal template for Shiny apps:

# Load the shiny package
library(shiny)

# Define UI for the application (this is where all visual elements will go)
ui <- fluidPage()

# Define the server logic
server <- function(input, output) {}

# Run the application by tying together the UI and server
shinyApp(ui = ui, server = server)

Adding text to a Shiny app is done by adding text inside the fluidPage() function as an argument, for example:

fluidPage(
  "Hello world"
)

The fluidPage() function can accept an arbitrary number of arguments. To include multiple text strings (or any other visual elements), you can place them all inside fluidPage() and separate them with commas, as you do with arguments to any other function.

Instructions

100 XP

Create a Shiny app that displays the text "Shiny is fun" by following these specific instructions:

  • Load the shiny package.
  • Create the UI for the Shiny app using the fluidPage() function.
  • Add the text "Shiny is fun" to the UI.