| name | shiny-pipeline-stage3 |
| description | Use this skill when a user wants to replace fake/synthetic data stubs in their Shiny app with real data from their workflow.R script. Triggers when users mention "stage 3 of the shiny pipeline", "replace fake data", "wire up real data", "swap stubs for real data", "integrate my workflow into shiny", or present a FAKEDATA_INDEX with items marked as still fake. Always use this skill before touching any fake_data.R or placeholder_fns.R stubs. Never silently replace fake data — every swap must be logged. |
Stage 3: Real Data Integration
Overview
Replace all FAKEDATA stubs and PLACEHOLDER functions with real data calls from workflow.R. Every swap is explicit, logged, and tested. Nothing is silently changed.
Inputs Required
app/ folder from Stage 2
workflow.R
FAKEDATA_INDEX.md with current status
If any are missing, ask the user before proceeding.
Step 1 — Audit the FAKEDATA_INDEX
Read every row of FAKEDATA_INDEX.md. For each item:
- Find its
real_replacement reference in workflow.R
- Confirm the object name, type, and structure
- Identify any dependencies (packages, file paths, external data) needed
- Flag blockers: missing files, API keys, heavy computations that need caching
Show the user an updated audit table before touching any code:
| ID | Real Object | Type | Dependencies | Blocker? |
|---|
| FAKE_001 | emissions_df | data.frame | data/emissions.csv | None |
| PLACEHOLDER_001 | counties_sf | sf object | sf, data/counties.gpkg | Needs leafletOutput in UI |
Get user confirmation before proceeding.
Step 2 — Integration Order
Replace in this order to minimize breakage:
- Simple data frames (Tier A panels first)
- Aggregated/model summaries (Tier B)
- Spatial outputs (requires UI changes: swap placeholder div →
leafletOutput)
- Network outputs (requires UI changes: swap placeholder div → custom render)
- Statistical model outputs (may require caching with
memoise or shinyCache)
Step 3 — Replacement Pattern
For each swap, follow this exact pattern:
In R/fake_data.R
Comment out (do not delete) the fake function:
In server.R
Replace the fake call with the real one, with a comment:
emissions_data <- reactive({
req(input$year_filter)
emissions_df |>
dplyr::filter(year == input$year_filter)
})
For Placeholders requiring UI changes
When a PLACEHOLDER panel needs a new Shiny output type (e.g., leafletOutput, plotOutput):
- Update
ui.R to replace the placeholder div with the correct output widget
- Update
server.R with the real render function
- Add required packages to the top of
app.R
Example for a leaflet map:
leaflet::leafletOutput("countyMap", width = "100%", height = "400px")
output$countyMap <- leaflet::renderLeaflet({
counties_sf |>
dplyr::left_join(emissions_data(), by = "county") |>
leaflet::leaflet() |>
leaflet::addTiles() |>
leaflet::addPolygons(fillColor = ~pal(nox_kg))
})
Step 4 — Dependency Hygiene
After all swaps, audit the top of app.R:
library(shiny)
library(dplyr)
library(ggplot2)
library(sf)
library(leaflet)
library(tidyr)
Remove any packages only needed for fake data generation (purrr::map for synthetic loops, etc.) if they're no longer used.
Step 5 — Remove FAKE Badges from UI
The [FAKE] UI badges added in Stage 1 must be removed for each panel that now has real data. Search www/styles.css and ui.R for .fake-badge and remove them panel by panel as each is verified.
Step 6 — Final FAKEDATA_INDEX
Mark every replaced item:
| ID | Description | Stage 3 Status |
|---|
| FAKE_001 | County emissions | ✅ Replaced with emissions_df |
| PLACEHOLDER_001 | County map | ✅ Replaced with leafletOutput + counties_sf |
If any items are still fake after this stage (e.g., blocked by missing data), mark them:
| ID | Description | Stage 3 Status |
|---|
| FAKE_003 | External API data | ❌ Blocked — API key not available |
Step 7 — Smoke Test Checklist
Before declaring done, confirm:
Deliverables
- Updated
app/ with real data integrations
- Final
FAKEDATA_INDEX.md showing all ✅ / ❌ statuses
- Brief summary of any remaining stubs and why they're blocked