Module 12 · Project 6 · Due the date on Canvas · Interactive Dashboards with Shiny · adaptive competency DV20
Wire the reactive graph
Mission progress0%
Begin by defining a KPI that can be reproduced.
Module 12 · Step 2 of 9 · Guided8–10 min
Why this lab Wire the reactive graph so one input change updates only what depends on it.
Shiny recomputes only the outputs that depend on a changed input. Build the dependency path in order: user input, reactive data, verified summary, rendered output.
Input→Reactive expression→Summary→Output
- Read inputs inside a reactive context. A line such as
selected <- input$campuswritten outside the server's reactive code cannot read the input. Wrapping it asreactive({ input$campus })records the dependency, so Shiny knows to rerun it when the campus changes.isolate()does the opposite: it reads a value without recording a dependency. - Call a reactive expression to get its value.
filtered_data <- reactive({ ... })creates something that behaves like a function. To retrieve the current filtered data, call it with parentheses:filtered_data(), inside a render function or another reactive. Written without the parentheses,filtered_datais the expression object, not the data. - Only what depends on the change is rerun. One shared reactive expression, called by every output that needs it, keeps the filter logic in one place, and a change of input invalidates exactly the outputs that depend on it.
Reactive graph builder loading…