---
title: "Assignment 6"
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. Housing eviction has received significant  public attention especially in the City of Oakland.  Let's examine the geographic clustering of housing eviction rates in the City of Oakland.

a. Use the Census API to bring in median household income (ID: B19013_001) from the 5-year 2015-19 American Community Survey for census tracts in California. Make sure to bring it in as a spatial object by setting geometry = TRUE.

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

b. For the object you created in (a), keep census tracts that are located in the City of Oakland. 

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

c. Download the file oakevict.csv from Canvas (Files - Week 6 - Assignment).  The file contains 2019 housing eviction rates oakevict for census tracts in Oakland. Read this file into R and merge it into the object you created in (b). 

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

d. Calculate the correlation between median household income and eviction rates.

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

e. Create a presentation-ready map of housing eviction rates using quantile breaks.

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

f. Construct a Moran scatterplot of housing eviction rates. Use queen contiguity and row-standardized weights. 

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

g. Calculate the Moran's I for housing eviction rates.  

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

h. Explain in your own words the conceptual difference between the correlation you calculated in 1d and the correlation you calculated in 1g. 


i. Are housing eviction rates geographically clustered based on your analysis in (e)-(g)? Explain why or why not. 



2. This article claims that Houston is the most racially integrated city in the United States. We'll examine this claim by calculating the spatial clustering of race/ethnic groups using the Moran's I for Houston metropolitan area data. Bring in the shapefile houstondems.zip into R.  This file contains data for census tracts in the Houston metropolitan areas.  The file is located on Canvas (Files - Week 6 - Assignment).  Save the file in an appropriate folder and unzip it to extract the shapefiles. The record layout for the file can be found here.  Consider the file to be clean and ready for analysis.

a. Read the file houstondems.shp into R. Create presentation-ready maps of percent non-Hispanic black, non-Hispanic white, non-Hispanic Asian, and Hispanic in the Houston metropolitan area using quantile breaks. 

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

b. Calculate Moran's I for percent non-Hispanic black, non-Hispanic white, non-Hispanic Asian, and Hispanic in Houston. Use queen contiguity and row-standardized weights. 

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

c. Summarize in your own words the degree to which each race/ethnic group is geographically clustered in Houston based on your answers in (b).


