Setup & Prerequisites
Complete this before the workshop. Allow about 30–45 minutes, plus download time for the spatial data.
1. Software
- R ≥ 4.3: https://cran.rstudio.com/
- RStudio (latest): https://posit.co/downloads/
- Hardware: 8 GB RAM or more (16 GB preferred), stable internet.
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
- Open
Module2_SpatialEpi.Rprojin RStudio. This sets the working directory so everyhere()path resolves. - The spatial data is in
spatial_files/anddata/(already in the repo). If you cloned without the large files, re-extractspatial_files.zipinto 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.