---
title: "Assignment 7"
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. In Assignment 6, we descriptively examined the claim that Houston is the most racially integrated city in the United States. Let's employ the segregation tools we learned this week to explore this claim even further.  Let's also compare Houston to Sacramento, a city that has also been proclaimed as among most racially diverse in the nation.  Read in the Houston and Sacramento shapefiles houstondems.shp and sacdems.shp, which can be found on Canvas in the zipped folder Assignment7.zip (Files - Week 7 - Assignment). A record layout of the data can be found [here](https://raw.githubusercontent.com/crd150/data/master/sac_houston_metro_tracts_record_layout.txt).

a. Calculate the Black/White, Hispanic/White and Asian/White Dissimilarity Indices for Houston and Sacramento. Present these values in a presentation-ready table(s). 

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

b. Calculate the Black/White, Hispanic/White and Asian/White Interaction Indices for Houston and Sacramento. Present these values in a presentation-ready table(s). 

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

c. Based on your answers to questions (a) and (b), which city is most segregated? Why? 

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

d. Instead of examining segregation at the city level, let’s find where it exists at the neighborhood level. Calculate the Location Quotient for Racial Residential Segregation (LQRSS) for the Hispanic, White, Black and Asian populations for each city. 

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


e. Show presentation-ready maps of the Hispanic LQRSS for each city. 

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

f. Let’s examine the socioeconomic variables that may be correlated with neighborhood Hispanic concentration in each city.  Calculate the correlation between the Hispanic LQRSS and percent of residents under 18 years old, percent of residents between 22 and 34, and percent foreign born in Houston. Do the same for Sacramento. Summarize the results in your own words, noting differences and similarities between the two cities. 

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


2. You will be calculating two-group segregation indices for the cities of Detroit and Los Angeles. Read in the Detroit and Los Angeles data files  detroitrace.csv and losangelesrace.csv, which can be found on Canvas in the zipped folder Assignment7.zip (Files - Week 7 - Assignment). You do not need to convert these data sets into sf objects.  Keep them as regular data frames (tibbles). A record layout of the data can be found [here](https://raw.githubusercontent.com/crd150/data/master/los_angeles_detroit_city_tracts_record_layout.txt). 

a. Calculate the Black/White, Hispanic/White, and Asian/White Dissimilarity indices for Detroit and Los Angeles. Present these values in a presentation-ready table(s). 

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

b. Calculate the Black/White, Hispanic/White, and Asian/White Interaction indices for Detroit and Los Angeles. Present these values in a presentation-ready table(s). 

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

c. Intuitively, if you get a high Dissimilarity index, you should get a low Interaction index. Comparing Detroit and Los Angeles Asian/White and Hispanic/White segregation, we find this to be the case. However, we find that Los Angeles has a larger Black/White Dissimilarity index than Detroit, but has a higher Black/White Interaction index. What is a good explanation for this finding? 

