6.2 Category 4 Variable 2: Female Employment
[Map]
<- paste0("<b>",countyGIS_map$name," (",countyGIS_map$FIPS,")</b>",
popupLabels_employment_female "<br><font color='",countyGIS_map$FontColorWinner,"'>",countyGIS_map$winner,
": ",
format(countyGIS_map$pctWinner*100,digits=4, trim=TRUE),
"%</font>",
"<br>Total votes: ", format(countyGIS_map$totalVotes,big.mark=",", trim=TRUE),
"<br>Percent Female Employment: ", format(round(countyGIS_map$pct_employment_female, 2),big.mark=",", trim=TRUE),
"%</font>"
%>%
) lapply(htmltools::HTML)
<- colorNumeric(
pal2 palette = colorRampPalette(c('red', 'white'))(length(countyGIS_map$pct_employment_female)),
domain = countyGIS_map$pct_employment_female, reverse=TRUE)
leaflet(countyGIS_map, options = leafletOptions(crsClass = "L.CRS.EPSG3857"), width="100%") %>%
addPolygons(weight = 0.5, color = "gray", opacity = 0.7,
fillColor = ~pal2(pct_employment_female), fillOpacity = 1, smoothFactor = 0.5,
label = popupLabels_employment_female,
labelOptions = labelOptions(direction = "auto")) %>%
addPolygons(data = stateGIS,fill = FALSE,color="black",weight = 1) %>%
addLegend(pal = pal2,values = ~countyGIS_map$pct_employment_female, opacity = 0.7, title = "% Female Employment",position = "bottomright")
[Scatter plot]
ggplot(countyGIS_stat, aes(pct_employment_female, pctGOP)) + geom_point(aes(alpha = pct_white, shape = ".")) + geom_smooth(method = "lm", se = FALSE)
[Regression]
# Estimate regression model
<- lm(pctGOP ~ pct_employment_female, data=countyGIS_stat)
pct_employment_female_reg
# Display model results
pander(summary(pct_employment_female_reg))
Estimate | Std. Error | t value | Pr(>|t|) | |
---|---|---|---|---|
(Intercept) | 1.203 | 0.04381 | 27.45 | 1.295e-148 |
pct_employment_female | -0.01334 | 0.001082 | -12.33 | 3.737e-34 |
Observations | Residual Std. Error | \(R^2\) | Adjusted \(R^2\) |
---|---|---|---|
3083 | 0.1574 | 0.04705 | 0.04675 |