Session - Basic User Interface (UI)
Input functions are often camelCase with the word Input
in their name:
sliderInput()
selectInput()
textInput()
numericInput()
Each have the first argument or parameter as inputId =
and is the link between the UI with the Server.
Like all functions the arguments names can be dropped and read by the order. So instead of:
you will often see:
First two argument names
All inputs need an inputId
and a label
so these are conventionally omitted.
inputId =
Only letters, numbers and underscores, never use:
It must also be unique so that the UI and Server are linked.
label =
parameterThe second argument or parameter is the human readable label for the control.
There are no restrictions for this at all but be mindful of the reader!
Mastering Shiny details a number of the controls including:
And there are always extension packages - {shinyWidgets}, {colorpicker}, {sorttable}
inputId
and label
)textOutput()
is usually paired with the server function renderText()
verbatimTextOutput()
is usually pared with the server function renderPrint()
{}
and reducing computationThe curly brackets are useful for running code over multiple lines:
But the recommendation is to do as little computation as possible in the render functions which means they are often omitted.
tableOutput()
is paired with the server function renderTable()
dataTableOutput()
is pared with the server function renderDataTable()
Let’s see what happens by creating a new shiny app, saving it and running it.
plotOutput()
is paired with the server function renderPlot()
Which of textOutput()
and verbatimTextOutput()
should each of the following render functions be paired with?
08:00
Putting the {}
back in to make the code clearer, parameters like res
and alt
for alt text go outside the brackets
Checking Alt Text (tip)
Inspect Element
.alt = "Scatterplot...
.Because Shiny is reactive and you may want Alt Text to reflect what is selected by the user:
Mastering Shiny by Hadley Wickham
Jumping Rivers blog about accessibility in R
Read more from Jumping Rivers on accessible standards in Shiny