Today, I learned some “Spatial Analysis” R packages (e.g., ggmap, tigris) from the last workshop of 8-week-long workshop series — R for the Social Sciences Weekly Workshops. It was a really great workshop! I leared a lot of R and Stats (e.g., Linear Models, Generalized Linear Models, autocorrelation, etc), even though the topics were more focused on Social Sciences.
Thanks to Raffaele Vacca, Tom Smith, and Till Krenz!
Here are some quick and simple code to plot Florida:
library(ggplot2) library(tidyverse) ## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ── ## ✓ tibble 3.0.6 ✓ dplyr 1.0.4 ## ✓ tidyr 1.1.2 ✓ stringr 1.4.0 ## ✓ readr 1.4.0 ✓ forcats 0.5.1 ## ✓ purrr 0.3.4 ## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ── ## x dplyr::filter() masks stats::filter() ## x dplyr::lag() masks stats::lag() # Get the shape data for the state of Florida and We need more detailed shape data to show county borders flr <- map_data("county") %>% filter(region == "florida") # Create a ggplot object that we can add layers to. flr_plot <- ggplot(data = flr, mapping = aes(x = long, y = lat)) + geom_map(map = flr, color = "orange", fill = "blue", aes(map_id=region)) + coord_quickmap() flr_plot
#of course, we can do more stuff, like adding county names...