This document presents interactive maps showing the relationship between COVID-19 case rates and other factors in New York City, including nursing home density and food store availability.
library(sf)
set.seed(123)
n <- 50
sample_data <- data.frame(
zipcode = paste0("1000", 1:n),
covid_rate_per_100k = runif(n, 1000, 5000),
nursing_homes_per_10k = runif(n, 0, 3),
food_stores_per_10k = runif(n, 1, 15),
population = sample(10000:100000, n, replace = TRUE)
)
coords <- matrix(runif(n*2, 0, 10), ncol = 2)
nyc_covid_data <- st_sf(
sample_data,
geometry = st_sfc(lapply(1:n, function(i) st_polygon(list(rbind(
coords[i,] + c(0,0),
coords[i,] + c(0.5,0),
coords[i,] + c(0.5,0.5),
coords[i,] + c(0,0.5),
coords[i,] + c(0,0)
)))), crs = 4326)
)
# Set tmap mode to interactive
tmap_mode("view")
# COVID-19 Case Rate Map
covid_map <- tm_shape(nyc_covid_data) +
tm_polygons("covid_rate_per_100k",
title = "COVID-19 Rate per 100,000",
palette = "YlOrRd",
popup.vars = c("ZIP" = "zipcode",
"COVID Rate" = "covid_rate_per_100k"),
id = "zipcode") +
tm_layout(title = "COVID-19 Case Rate",
frame = TRUE)
# Nursing Home Density Map
nursing_map <- tm_shape(nyc_covid_data) +
tm_polygons("nursing_homes_per_10k",
title = "Nursing Homes per 10,000",
palette = "Blues",
popup.vars = c("ZIP" = "zipcode",
"Nursing Home Density" = "nursing_homes_per_10k"),
id = "zipcode") +
tm_layout(title = "Nursing Home Density",
frame = TRUE)
# Food Store Density Map
food_map <- tm_shape(nyc_covid_data) +
tm_polygons("food_stores_per_10k",
title = "Food Stores per 10,000",
palette = "Greens",
popup.vars = c("ZIP" = "zipcode",
"Food Store Density" = "food_stores_per_10k"),
id = "zipcode") +
tm_layout(title = "Food Store Density",
frame = TRUE)
# Combine maps side by side
combined_tmaps <- tmap_arrange(covid_map, nursing_map, ncol = 2)
# Display the combined maps
combined_tmaps
# Save the combined maps as HTML
tmap_save(combined_tmaps,
filename = "nyc_covid_nursing_maps.html",
width = 1200,
height = 800)
These interactive maps allow us to visualize and compare COVID-19 case rates with nursing home density across New York City ZIP codes. The maps enable exploration of potential relationships between these variables and support the analysis of spatial patterns.