-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the APS Baseline Dashboard project! This wiki documents everything you need to get the code running locally, understand the data pipeline, and deploy the Quarto-based dashboard to GitHub Pages.
- Project Overview
- Repository Structure
- Prerequisites
- Quick Start
- Obtaining a REDCap API Token
- Detailed Usage
- Local Development Workflow
- Resetting the R Environment
- Deployment to GitHub Pages
- Troubleshooting & FAQ
- Contributing
The APS Baseline Dashboard visualises REDCap survey submissions for the APS (Active Project Surveillance) initiative. Data are retrieved from REDCap, stored locally in a lightweight DuckDB database, and surfaced in an interactive Quarto Dashboard (aps-dashboard.qmd).
Key components:
-
data_operations.rโ Pulls data from REDCap and writes it to a DuckDB file. -
aps-dashboard.qmdโ Quarto file that queries the DuckDB and builds the dashboard UI. -
renv.lockโ Exact package snapshot for reproducibility.
โโโ data_operations.r # Data-ingestion script
โโโ aps-dashboard.qmd # Quarto dashboard source
โโโ renv.lock # Package lockfile (renv)
โโโ assets/
โ โโโ data/ # DuckDB database lives here after first run
โโโ README.md / .github/ # (recommended) project meta & workflows
Tip: Keep all generated objects (DuckDB, Quarto
_site/ordocs/output) out of version control via.gitignore.
| Tool | Minimum Version | Install Command |
|---|---|---|
| R | 4.5.0 | https://cran.r-project.org |
| renv | 1.0.0 | install.packages("renv") |
| Quarto CLI | 1.4.550 | https://quarto.org/docs/get-started/ |
| Git | 2.40 | https://git-scm.com |
All other R packages (e.g., duckdb, REDCapR) are installed automatically by
renv::restore().
# 1. Clone the repository
git clone https://github.com/your-org/aps-dashboard.git
cd aps-dashboard
# 2. Restore all R packages
R -q -e "renv::restore()"
# 3. Store your REDCap API token (one-off, project-local)
echo "REDCAP_API_TOKEN=<your-token>" >> .Renviron
# To update the dashboard, rerun steps 4 and 5 only.
# 4. Ingest data (creates assets/data/APS-DATA.duckdb)
Rscript data_operations.r
# 5. Render & preview the dashboard
quarto preview aps-dashboard.qmd๐ Security:
.Renvironshould be listed in.gitignoreso your token never reaches version control.
To query data you need a user-specific API token issued by the REDCap project you have access to.
- Log in to REDCap at https://redcap.uth.tmc.edu/.
- Open the APS Baseline project (or whichever project you need).
- In the left sidebar, expand Applications โ API.
- If you donโt see a token, click Request API token and wait for approval.
- Once approved, copy the 32-character string shown as Your API token.
- Add it to a project-local
.Renvironfile:echo 'REDCAP_API_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' >> .Renviron
- Open a new terminal (or restart RStudio) so the environment variable is loaded.
Scope: Tokens are project-specificโgenerate one for each REDCap project you work with.
renv.lock pins exact package versions. From your project root run:
renv::restore()This installs all required packages into an isolated project library.
data_operations.r authenticates via your REDCAP_API_TOKEN and retrieves records:
redcap_read(
redcap_uri = "https://redcap.uth.tmc.edu/api/",
token = Sys.getenv("REDCAP_API_TOKEN"),
continue_on_error = FALSE
)The script writes the fetched dataframe to assets/data/APS-DATA.duckdb:
dbWriteTable(con, "APS-BL", data$data, overwrite = TRUE)aps-dashboard.qmd uses the dashboard format. Render once:
quarto render aps-dashboard.qmdThe default output directory is _site/ (configurable via quarto.yml).
-
Pull latest code โ
git pull origin main -
Update data โ
Rscript data_operations.r -
Iterate on visuals โ Edit
aps-dashboard.qmdโ Quarto auto-reload -
Commit changes โ
git commit -am "Add new KPI" -
Push โ
git push origin main
If renv::restore() fails or you need a clean slate:
- Rename or delete
renv.lock. - Re-initialise renv:
renv::init(bare = TRUE) # creates a new lockfile renv::restore(lockfile = NULL) # bypasses lockfile during restore
- Install any extra packages, then run
renv::snapshot(force = TRUE). - Commit the new
renv.lockonce everything renders correctly.
The dashboard is built and served directly from the main branch.
-
Configure Quarto to output to
/(default). -
Render the site:
quarto render aps-dashboard.qmd
-
Commit and push the generated files:
git add . git commit -m "Render site" git push origin main
-
In Repository โ Settings โ Pages, set Source to
mainbranch and/since you render to root.
| Issue | Fix |
|---|---|
_reproducible snapshot ... failed_ |
Delete .renv/ and run renv::restore()
|
| Dashboard shows 0 submissions | Confirm .Renviron contains your token and that your REDCap user has export rights |
| Quarto command not found | Install Quarto CLI and ensure itโs on your PATH |
| Pages 404 after deploy | Wait a few minutes; Pages CDN caches. Confirm site in /docs on main
|
- Fork โ Create feature branch (
feat/new-chart) โ Commit โ Open PR. - Run
lintrand ensure Quarto renders without errors. - Describe visual or data changes clearly in the PR summary.