Setup & Prerequisites

Complete this before the workshop. Allow about 30–45 minutes, plus download time for the spatial data.

1. Software

2. R packages

Run the bundled install script once:

source("resources/install_required_packages.R")

It installs: tidyverse, here, patchwork, janitor, rio, sf, ggspatial, raster, exactextractr, tidygeocoder, leaflet, mapview, spdep, rgeoda, HistData.

WarningSystem dependencies for sf

sf, rgeoda and exactextractr need GDAL, GEOS and PROJ. On macOS: brew install gdal geos proj. On Ubuntu: apt install libgdal-dev libgeos-dev libproj-dev. On Windows the CRAN binaries include these, so no extra steps.

3. Project & data

  1. Open Module2_SpatialEpi.Rproj in RStudio. This sets the working directory so every here() path resolves.
  2. The spatial data is in spatial_files/ and data/ (already in the repo). If you cloned without the large files, re-extract spatial_files.zip into the project root.

4. Pre-flight check

library(sf); library(tidyverse); library(here)
# prints the number of India state polygons:
sf::st_read(here("spatial_files", "India_State_Boundary.shp")) |> nrow()

A non-zero row count means you are ready. See GIS-basics.pdf for a primer, and resources/prerequisites.qmd for more detail.