29.7 Shiny

  • Shiny interactions occur on the server-side, meaning you can write interactive apps without knowing JavaScript, but you need a server to run them on.

  • To call Shiny code from a Quarto document, add server: shiny to the YAML header:

title: "Shiny Web App"
format: html
server: shiny
  • Then you can use the “input” functions to add interactive components to the document:
library(shiny)

textInput("name", "What is your name?")
numericInput("age", "How old are you?", NA, min = 0, max = 150)
  • And you also need a code chunk with chunk option context: server which contains the code that needs to run in a Shiny server.