---
title: "Assignment 5"
subtitle: CRD 150
author: YOUR FULL NAME HERE
date: INSERT DATE HERE
output: 
  html_document:
    theme: cosmo
---


```{r setup, include=FALSE}
# Do not edit this code block/chunk
knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message = FALSE)
knitr::opts_knit$set(progress = TRUE, verbose = TRUE)
```

```{r}
#Load in all necessary packages using the function library()
```


1. CalEnviroScreen is a mapping tool that helps identify California communities that are most affected by many sources of pollution, and where people are often especially vulnerable to pollution's effects. Download the CalEnviroScreen California tract-level shapefile from the the official CES website. The file is also located on Canvas in the Week 5 Assignment folder. Make sure to download it in an appropriate folder on your hard drive. Unzip the folder. 

a. Read the file into R and keep tracts in Yolo county. 

```{r}
#Add comment explaining code
```


b. Make a static presentation-ready map of the variable PM2_5 for Yolo county tracts, which is the level of pollution based on PM 2.5 levels (higher PM 2.5, more pollution), using quantile breaks. Summarize in your own words the geographic distribution of pollution burden in Yolo county based on the map. 

```{r}
#Add comment explaining code
```


c. Produce static presentation-ready maps of PM2_5 using three other classifications other than quantile breaks. Describe if and how your general impression of where high and low pollution burden neighborhoods are located in the county change across the different classifications.

```{r}
#Add comment explaining code
```


2. We are gradually receding from a global health crisis marked by profound human suffering. Analyzing the demographic, health and job characteristics of communities reveals that some places were disproportionately affected by this suffering. In particular, we found that communities with no or unstable internet access are at a disadvantage given that employment, medical care (telemedicine), education and other important services were and still are primarily conducted online at home. Let's visually examine the association between internet access and race/ethnicity in Sacramento county census tracts.

a. Using the Census API, bring in 2019-2023 total, non-Hispanic white, non-Hispanic black, non-Hispanic Asian, and Hispanic populations for census tracts in Sacramento county.  Check Lab 3 for the appropriate variable IDs. Make sure to bring in spatial data by using geometry = TRUE. Also make sure to clean the data. Calculate the percent Asian, white, Black and Hispanic variables. 

```{r}
#Add comment explaining code
```


b. Bring into R the 2019-2023 percent of households without a cable, Fiber Optic, or DSL internet connection for Sacramento county census tracts from PolicyMap (from the PolicyMap site, click on Quality of Life, Computer and Internet Access, Household Internet Access, Without High Speed Internet Access, and No Cable, Fiber Optic or DSL). Make sure to clean the data. 


```{r}
#Add comment explaining code
```

c. Merge the percent of households without a broadband, cable, Fiber Optic, or DSL internet connection to the sf census tracts object you created in (a).

```{r}
#Add comment explaining code
```

d. Create static presentation-ready maps of percent non-Hispanic black, non-Hispanic white, non-Hispanic Asian, and Hispanic using quantile breaks.

```{r}
#Add comment explaining code
```

e. Create a static presentation-ready map of the percent of households without a broadband, cable, Fiber Optic, or DSL internet connection using quantile breaks. 


```{r}
#Add comment explaining code
```

f. Calculate the correlation between percent of households without a cable, Fiber Optic, or DSL internet connection and percent non-Hispanic black, non-Hispanic white, non-Hispanic Asian, and Hispanic. Present the results in a presentation-ready table using flextable().

```{r}
#Add comment explaining code
```

g. Based on the correlations in (f) and a visual comparison of the maps you created in (d) and (e), summarize in your own words the association between racial/ethnic composition and percent of households without a broadband, cable, Fiber Optic, or DSL internet connection.

