Historical Markers in The United States

July 4, 2023

Loading the data

This post explores the tidy Tuesday dataset for 2023-07-04, it is concerned with historical markers in the in The United States. Let's load the data and take a quick look at it:

Show the code
pacman::p_load(tidyverse,highcharter,leaflet) # Load relevant packages 
theme_set(theme_minimal()) # Set the default theme to minimal

historical_markers <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-07-04/historical_markers.csv')

glimpse(historical_markers)

The dataset contains geographical information such as the latitude and longitude coordinates. We also have information about the historical marker, such as where it is located, a brief summary etc. Let's proceed to pick out a few trends.

Data Visualisation

What are the top 10 states with the most historical markers?

Show the code
historical_markers %>% 
  group_by(state_or_prov) %>% 
  count(sort = TRUE,name = "Count") %>% 
  ungroup() %>% 
  slice_head(n = 10) %>% 
  ggplot(aes(fct_reorder(state_or_prov,Count),Count))+
  geom_col(alpha=0.8, fill="midnightblue")+
  scale_y_continuous(labels = scales::comma_format(), expand = c(0.01,0.01))+
  xlab("")+
  ylab("")+
  coord_flip()+
  theme(plot.title.position = "plot")+
  ggtitle(label = "Number of Historical markers by state")

Let's plot the number of historical markers on a map using a continuous scale, to create a choropleth map:

Show the code
historical_markers %>% 
  group_by(state_or_prov) %>% 
  count(sort = TRUE,name = "Count") %>% 
  ungroup() -> hist_count

mapdata <- get_data_from_map(download_map_data("custom/usa-and-canada"))

# glimpse(mapdata)

mapdata %>% 
  filter(country == "United States of America") ->mapdata

hcmap(
  "countries/us/us-all",
  data = hist_count,
  value = "Count",
  joinBy = c("name", "state_or_prov"),
  name = "Number of Historical Markers",
  dataLabels = list(enabled = TRUE, format = "{point.name}"),
  borderColor = "black",
  borderWidth = 0.1,
   tooltip = list()
) %>% 
  hc_title(
    text= "Historical Markers by State"
  ) %>% 
   hc_colorAxis(
    minColor = "#fbf2ff",
    maxColor = "#7300a7"
  ) %>% 
    hc_mapNavigation(enabled = TRUE)

Again we see the same pattern in the first visual, but now projected onto a map. You can even zoom in if you wish to do so. It looks like Texas has the most historical markers, a total of 10,741. It would be interesting to see the locations of the markers as points, given how many there are we can also cluster them to identify hot spots:

Show the code
historical_markers %>% 
  filter(state_or_prov == "Texas") %>%  # Filter for Texas only
  select(title,latitude_minus_s,longitude_minus_w) -> Texas_hist

leaflet(Texas_hist) %>% addTiles() %>% 
  addMarkers(~longitude_minus_w,~latitude_minus_s,clusterOptions = 
               markerClusterOptions(), label = ~title,popup = ~title)

Again we can zoom in and out top get a sense of the geographical distribution of the markers. The northernmost historical marker is The Oslo Community in contrast the southernmost marker is the Raab Plantation. What other patterns can you find in the data? What are the eastern and westernmost historical markers in Texas?