The ui.R of the minimal example

The ui.R file is a description of the UI, and is often the shortest and simplest part of a Shiny application. In the following code, note the use of the # character, which marks lines of code as comments that will not be run, but which are for the benefit of the humans producing the code:

fluidPage(                                 # Line 1 
  titlePanel("Minimal application"),       # Line 2 
  sidebarLayout(                           # Line 3 
    sidebarPanel(                          # Line 4 
      textInput(inputId = "comment",       # Line 5 
                label = "Say something?",  # Line 6 
                value = ""                 # Line 7 
                )),                        # Line 8 
    mainPanel(                             # Line 9 
      h3("This is you saying it"),         # Line 10 
      textOutput("textDisplay")            # Line 11 
    ) 
  ) 
) 

The following list is an explanation of each line:

  • Line 1: Flexible layout function
  • Line 2: Title
  • Line 3 ...

Get Web Application Development with R Using Shiny - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.