Import the Data and Create a Data Frame
# import the data set using read.csv function with no columns.
Redistricting <- read.csv('https://raw.githubusercontent.com/JHALAK-sps/Fall-2022/master/redistricting-alternate-maps.csv', header=TRUE)
dfDis <- as.data.frame(Redistricting)
#overview of the data
head(Redistricting)
## ï..state_abbr state_name
## 1 AK Alaska
## 2 AL Alabama
## 3 AR Arkansas
## 4 AZ Arizona
## 5 CA California
## 6 CO Colorado
## rep_map
## 1 https://projects.fivethirtyeight.com/redistricting-2022-maps/alaska/
## 2 https://projects.fivethirtyeight.com/redistricting-2022-maps/alabama/committee_proposal_1/
## 3 https://projects.fivethirtyeight.com/redistricting-2022-maps/arkansas/sb723/
## 4 https://projects.fivethirtyeight.com/redistricting-2022-maps/arizona/draft_12_1/
## 5 https://projects.fivethirtyeight.com/redistricting-2022-maps/california/commission_draft_plan/
## 6 https://projects.fivethirtyeight.com/redistricting-2022-maps/colorado/final_plan/
## rep_map_r_districts rep_map_d_districts rep_map_c_districts
## 1 1 0 0
## 2 6 1 0
## 3 4 0 0
## 4 6 2 1
## 5 7 39 6
## 6 3 4 1
## rep_map_avg_r_chances rep_map_avg_d_chances rep_map_median_pvi
## 1 0.9147285 0.085271529 -14.6202800
## 2 0.8556325 0.144367459 -3.9899677
## 3 0.9908803 0.009119694 -0.2612317
## 4 0.6626404 0.337359561 -1.0415907
## 5 0.1873006 0.812699428 3.1391523
## 6 0.4783516 0.521648391 -5.0415824
## dem_map
## 1 https://projects.fivethirtyeight.com/redistricting-2022-maps/alaska/
## 2 https://projects.fivethirtyeight.com/redistricting-2022-maps/alabama/plaintiffs_plan_c/
## 3 https://projects.fivethirtyeight.com/redistricting-2022-maps/arkansas/hb1962/
## 4 https://projects.fivethirtyeight.com/redistricting-2022-maps/arizona/preliminary_2/
## 5 https://projects.fivethirtyeight.com/redistricting-2022-maps/california/commission_approved/
## 6 https://projects.fivethirtyeight.com/redistricting-2022-maps/colorado/preliminary/
## dem_map_r_districts dem_map_d_districts dem_map_c_districts
## 1 1 0 0
## 2 5 2 0
## 3 3 0 1
## 4 4 3 2
## 5 7 43 2
## 6 3 4 1
## dem_map_avg_r_chances dem_map_avg_d_chances dem_map_median_pvi
## 1 0.9147285 0.08527153 -14.620280
## 2 0.7382285 0.26177148 -14.805300
## 3 0.8457178 0.15428219 -7.462784
## 4 0.5681425 0.43185754 4.290196
## 5 0.1779064 0.82209360 3.169977
## 6 0.4495653 0.55043475 -1.831909
## com_map
## 1 https://projects.fivethirtyeight.com/redistricting-2022-maps/alaska/
## 2 https://projects.fivethirtyeight.com/redistricting-2022-maps/alabama/plaintiffs_plan_c/
## 3 https://projects.fivethirtyeight.com/redistricting-2022-maps/arkansas/hb1962/
## 4 https://projects.fivethirtyeight.com/redistricting-2022-maps/arizona/preliminary_3/
## 5 https://projects.fivethirtyeight.com/redistricting-2022-maps/california/commission_draft_plan/
## 6 https://projects.fivethirtyeight.com/redistricting-2022-maps/colorado/staff_plan_1/
## com_map_r_districts com_map_d_districts com_map_c_districts
## 1 1 0 0
## 2 5 2 0
## 3 3 0 1
## 4 4 2 3
## 5 7 39 6
## 6 3 3 2
## com_map_avg_r_chances com_map_avg_d_chances com_map_median_pvi
## 1 0.9147285 0.08527153 -14.620280
## 2 0.7382285 0.26177148 -14.805300
## 3 0.8457178 0.15428219 -7.462784
## 4 0.6232405 0.37675947 4.080983
## 5 0.1873006 0.81269943 3.139152
## 6 0.4743700 0.52562999 -5.939080