Task 1: Using the code I have provided above, install and load the tidyverse package, and create the Inc2022 and Inc2017 data frames. Accompany the code with a brief explanation of how the code works.

Response: The code imbedded (tidyverse) allows you to download other pieces of data. The other two pieces give you the raw data you need to use but not organized. if(!require(tidyverse))install.packages(“tidyverse”)

library(tidyverse)

Inc2022 <- read.csv(“https://drkblake.com/wp-content/uploads/2024/02/Inc2022.csv”)

Inc2017 <- read.csv(“https://drkblake.com/wp-content/uploads/2024/02/Inc2017.csv”)

Task 2:  Write R code that uses the left_join() function to merge the Inc2022 and Inc2017 data frames into a new data frame called Income, then shows the first 10 rows of the Income data frame. Explain which data frame was your “to” data frame, which was your “from” data frame, and which variables served as your “key column” variables.

Response: The Left_ join is used to merge the Inc2022 and Inc2017 data is used to merge into a data frame called income. The Inc2022 is the “to” and Inc2017 is “from” which both puts the data into a district, county, and significance column to seperate the data.

Income <- left_join(Inc2022,Inc2017, by = join_by(GEOID == GEOID))

Income <- Income %>% mutate(Change = HHInc2022 - HHInc2017) head(Income, 10)

LevelbyCounty <- Income %>% group_by(County, Level) %>% summarize(Count = n()) %>% pivot_wider(names_from = Level, values_from = Count)

RichDistricts <- Income %>% filter(Level == “$100k+”) head(RichDistricts, 10)

RichDistricts <- RichDistricts %>% arrange(desc(HHInc2022)) head(RichDistricts, 10)