-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeserts.Rmd
45 lines (37 loc) · 1.43 KB
/
deserts.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
title: "deserts"
author: "Samruddhi Naik"
date: '2022-07-04'
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(tidycensus)
library(tidyverse)
library(ggthemes)
library(jsonlite)
```
The map we made shows the percent of food deserts in Cook County.
```{r}
json_url <- "https://services1.arcgis.com/RLQu0rK7h4kbsBq5/arcgis/rest/services/Store_Locations/FeatureServer/0/query?where=State%20%3D%20'IL'%20AND%20County%20%3D%20'COOK'&outFields=Store_Name,State,County,Longitude,Latitude&outSR=4326&f=json"
county_stores <- fromJSON(json_url)
county_stores <- county_stores$features$attributes
county_map <- get_acs(geography = "tract",
variables = "B06012_002", year = 2018,
state = "Illinois", county = "Cook County",
geometry = TRUE, summary_var = "B02001_001") |>
mutate(Percent = (estimate/summary_est)*100)
county_map |>
ggplot(aes(fill = Percent, color = Percent)) +
geom_sf() +
scale_fill_viridis_c(direction = -1) +
scale_color_viridis_c(direction = -1) +
geom_point(data = county_stores, inherit.aes = FALSE,
aes(x = Longitude, y = Latitude),
size = 0.5) +
labs(title = "Grocery Stores and Income in Cook County",
subtitle = "Cook County has a small food desert in the south.",
fill = "Percent",
caption = "SNAP Retailer Locator, U.S. Department of Agriculture Food and Nutrition Service") +
theme_void()
```