6.1 Category 4 Variable 1: Male Employment
[Map]
<- paste0("<b>",countyGIS_map$name," (",countyGIS_map$FIPS,")</b>",
popupLabels_employment_male "<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 Male Employment: ", format(round(countyGIS_map$pct_employment_male, 2),big.mark=",", trim=TRUE),
"%</font>"
%>%
) lapply(htmltools::HTML)
<- colorNumeric(
pal palette = colorRampPalette(c('blue', 'white'))(length(countyGIS_map$pct_employment_male)),
domain = countyGIS_map$pct_employment_male, reverse=TRUE)
leaflet(countyGIS_map, options = leafletOptions(crsClass = "L.CRS.EPSG3857"), width="100%") %>%
addPolygons(weight = 0.5, color = "gray", opacity = 0.7,
fillColor = ~pal(pct_employment_male), fillOpacity = 1, smoothFactor = 0.5,
label = popupLabels_employment_male,
labelOptions = labelOptions(direction = "auto")) %>%
addPolygons(data = stateGIS,fill = FALSE,color="black",weight = 1) %>%
addLegend(pal = pal,values = ~countyGIS_map$pct_employment_male, opacity = 0.7, title = "% Male Employment",position = "bottomright")
[Scatter plot]
ggplot(countyGIS_stat, aes(pct_employment_male, pctGOP)) +
geom_point(aes(alpha = pct_white, shape = ".")) +
geom_smooth(method = "lm", se = FALSE)
[Regression]
# Estimate regression model
<- lm(pctGOP ~ pct_employment_male, data=countyGIS_stat)
pct_employment_male_reg
# Display model results
pander(summary(pct_employment_male_reg))
Estimate | Std. Error | t value | Pr(>|t|) | |
---|---|---|---|---|
(Intercept) | 0.4935 | 0.03789 | 13.03 | 8.617e-38 |
pct_employment_male | 0.004242 | 0.0009424 | 4.501 | 0.000007021 |
Observations | Residual Std. Error | \(R^2\) | Adjusted \(R^2\) |
---|---|---|---|
3083 | 0.1607 | 0.006532 | 0.006209 |