6.1 Category 4 Variable 1: Median Rent

6.1.1 Map of Median Rent in the United States

rent.bins<-c(0,500,750,1000,1500,2000,2500)
pal <- colorBin("Greens", metadataGIS$median_rent, bins = rent.bins, reverse=FALSE)

leaflet(metadataGIS, options = leafletOptions(crsClass = "L.CRS.EPSG3857"), width="100%") %>%
  addPolygons(weight = 0.5, color = "gray", opacity = 0.7,
    fillColor = ~pal(median_rent), fillOpacity = 1, smoothFactor = 0.5,
    label = popupPlus("Median Rent", metadataGIS$median_rent, "number"),
    labelOptions = labelOptions(direction = "auto")) %>%
    addPolygons(data = stateGIS,fill = FALSE,color="black",weight = 1) %>%
    addLegend(pal = pal,values = ~metadataGIS$median_rent, opacity = 1, title = "Median Rent per Month",position = "bottomright")

6.1.2 Graph and Regression of Median Rent and % of GOP Votes

ggplot(metadata,aes(x=median_rent,y=pctGOP*100,size=totalVotes))+
  geom_point(alpha=.2,color="Blue")+
  geom_smooth(method="lm",color="Black",alpha=.8,show.legend = FALSE)+
  geom_smooth(method="loess",color="red",alpha=.8,show.legend = FALSE)+
  labs(title="Cost of Rent as an explainatory variable for Voting Patterns",x="Median Cost of Rent",y="People who voted GOP (%)", size = "Total Votes")

model4.1<-lm(pctGOP~median_rent,data=metadata)
stargazer(model4.1, 
          type = "html", 
          report=('vc*p'),
          keep.stat = c("n","rsq","adj.rsq"), 
          notes = "<em>&#42;p&lt;0.1;&#42;&#42;p&lt;0.05;&#42;&#42;&#42;p&lt;0.01</em>", 
          notes.append = FALSE)
Dependent variable:
pctGOP
median_rent -0.0004***
p = 0.000
Constant 0.956***
p = 0.000
Observations 3,108
R2 0.280
Adjusted R2 0.279
Note: *p<0.1;**p<0.05;***p<0.01