Shiny Dashboard for Public Health Trends
Build an interactive dashboard with R Shiny that shows public health trends over time, for example weekly case counts or vaccination rates by country or region, from a public dataset such as Our World in Data. Users choose regions, a date range and a measure, and the charts and summary numbers update instantly: a line chart comparing regions, a smoothed trend, and key figures such as the total, the peak and the change over the last weeks. You'll learn loading and reshaping real data with dplyr and tidyr, reactive programming in Shiny, building a clean layout with bslib, ggplot2 charts that respond to inputs, and presenting health data carefully and accurately.
- Estimate
- ~8h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
Shiny · ggplot2 · dplyr
Project roadmap
- 01
Set up the app
~1hCreate app.R with a page built with bslib (page_sidebar), a sidebar for the filters, and a main area for charts and summary cards. Pick a public dataset (for example an Our World in Data COVID-19 or vaccination file, or a public influenza surveillance dataset) and note its source and license on the page. Done when: the app runs and shows the empty layout with the data source noted.
- 02
Load and prepare the data
~1.5hLoad the CSV with readr once when the app starts (not on every interaction), keep the needed columns, parse the dates, and reshape it with tidyr into a long format (date, region, measure and value). Check for missing values and negative numbers (which sometimes appear as data corrections), and decide how to show them. Done when: the prepared data frame has one row per date, region and measure.
- 03
Add the filters
~1.5hAdd a selectizeInput for regions (several allowed, with a limit), a dateRangeInput limited to the data's range, a selectInput for the measure, and an option for values per 100,000 people where population data exists. Build one reactive() that filters the data from these inputs, and use req() so nothing runs with empty inputs. Done when: changing a filter updates the filtered data (checked with a quick table).
- 04
Build the trend chart
~1.5hRender a ggplot2 line chart of the filtered data with one line per region, a 7-day rolling average option (computed with slider or zoo), readable date labels, a clear title with the measure and units, and a caption with the data source. Optionally make it interactive with plotly. Done when: the chart updates with the filters and is easy to read.
- 05
Add summary figures
~1hShow value boxes for the selected period: the total, the peak value with its date, the latest value, and the change compared with 4 weeks earlier as a percentage (with an arrow). Handle regions with no data in the period gracefully. Done when: the summary figures match the chart and update with the filters.
- 06
Test it
~1.5hMove the data preparation and summary calculations into functions and test them with testthat on a small made-up dataset (per-capita values, rolling averages and the 4-week change). Test the server with shiny::testServer, changing inputs and checking outputs. Done when: all tests pass.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack