Skip to content

thedbcooper/R-GIS-Mapping-Example

Repository files navigation

Choropleth Maps in R using {ggplot2}

This repo contains example code for creating a choropleth map using R programming and the following primary packages: {sf}, {ggplot2}. It retrieves and cleans data from internet sources, derives "pretty" break intervals for the primary variable (life expectancy), then outputs a png. The {classInt} package provides functions to define breaks using other methods, such as "jenks."

Setup

  1. Clone the project from GitHub into a local folder
  2. Open the RProject in RStudio or open the folder in Positron
  3. If {renv} does not bootstrap/install itself, install manually using
    1. install.packages("renv")
    2. renv::init() -> Choose option 1 to restore project
  4. Click on run.R in Files pane to open the source script
  5. Run all

{renv} documentation: Collaborating with renv

Acknowledgements

  1. KY Gov Maps Open Data Portal
  2. County Health Rankings

About

Example R code for creating a choropleth map using the sf and ggplot2 packages.

Topics

Resources

Stars

Watchers

Forks

Languages