Interactive Map in R with Shiny and Leaflet
R, Shiny, Leaflet, interactive map, CDC data, public health, data visualization
This project uses Shiny and Leaflet in R to create an interactive map of CDC data on nutrition, exercise, and obesity across the United States. The app was developed in partnership with Hayden Vaughn and is hosted on shinyapps.io.
You can explore the live version here:
👉 Full Shiny App
Workflow
- Data source
- CDC public health dataset covering state-level nutrition, physical activity, and obesity indicators.
- Shiny application
- Built with
shinyfor the app structure and reactivity.
- User interface allows selection of different health indicators.
- Built with
- Leaflet map
- Used
leafletfor the interactive choropleth map.
- States are shaded according to health indicator values, with hover/click tooltips.
- Used
- Deployment
- Hosted on shinyapps.io for public access.
Application Preview
Discussion
The finished application allows users to explore public health trends interactively. By selecting variables, users can compare how nutrition, exercise, and obesity differ across states.
This project highlights how R’s Shiny and Leaflet packages can be combined to produce data-driven tools for public health communication.
FAQ: Building Interactive Maps with Shiny and Leaflet
How do I add an interactive map to a Shiny app?
Use leafletOutput() in the UI and renderLeaflet() in the server function.
How do I color states or regions by value?
Create a color palette with colorNumeric() or colorBin() and apply it to polygons.
Can this app be deployed for free?
Yes. Shiny apps can be deployed to shinyapps.io with a free plan, though usage limits apply.
What types of datasets work best with Leaflet?
Any dataset with geographic boundaries or coordinates, such as shapefiles, GeoJSON, or state/county-level data.
Oliver F. Anderson, MS – Computational Biologist, Data Scientist, and Research Consultant based in Portland, Oregon. I design data-driven solutions in bioinformatics, machine learning, and AI automation for research and biotech.
Back to top