Lecture 20
Cornell University
INFO 3312/5312 - Spring 2024
April 11, 2024
Navigation Bar and Pages — Icon, title, and author along with links to sub-pages (if more than one page is defined).
Sidebars, Rows & Columns, and Tabsets — Rows and columns using markdown heading (with optional attributes to control height, width, etc.). Sidebars for interactive inputs. Tabsets to further divide content.
Cards (Plots, Tables, Value Boxes, Content) — Cards are containers for cell outputs and free form markdown text. The content of cards typically maps to cells in your notebook or source document.
Each code chunk makes a card, and can take a title
Each code chunk makes a card, doesn’t have to have a title
Text content
Value boxes
Expanding cards
https://quarto.org/docs/dashboards/interactivity/shiny-r
For interactive exploration, some dashboards can benefit from a live R backend
To do this with Quarto Dashboards, add interactive Shiny components
Deploy with or without1 a server!
Include runtime: shiny
in YAML header
Include a context: server
chunk which replaces server.R
context
chunk option---
title: "Old Faithful"
format: html
server: shiny
---
```{r}
sliderInput("bins", "Number of bins:",
min = 1, max = 50, value = 30)
plotOutput("distPlot")
```
```{r}
#| context: server
output$distPlot <- renderPlot({
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
```
```{r}
#| context: setup
#| include: false
# load libraries
library(dplyr)
# load data
dataset <- import_data("data.csv")
dataset <- sample_n(dataset, 1000)
```
context: setup
- execute code in both rendering and serving contexts
```{r}
#| context: data
#| include: false
dataset <- import_data("data.csv")
dataset <- sample_n(dataset, 1000)
```
context: data
- define prerendered data chunks that are run during rendering, then loaded with the application
ae-17
ae-17
(repo name will be suffixed with your GitHub name).