4.2 Category 2 Variable 2: Asian Adults

[Map]

popupLabels_AsianAge <- paste0("<b>",countyGIS_map$name," (",countyGIS_map$FIPS,")</b>",
                    "<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 Asian Age: ", format(round(countyGIS_map$pct_asianage, 2),big.mark=",", trim=TRUE),
                    "%</font>"
                    ) %>% 
              lapply(htmltools::HTML)
pal <- colorNumeric(
  palette = colorRampPalette(c('Orange', 'White'))(length(countyGIS_map$pct_asianage)), 
  domain = countyGIS_map$pct_asianage, 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_asianage), fillOpacity = 1, smoothFactor = 0.5,
    label = popupLabels_AsianAge,
    labelOptions = labelOptions(direction = "auto")) %>%
    addPolygons(data = stateGIS,fill = FALSE,color="black",weight = 1) %>%
    addLegend(pal = pal,values = ~countyGIS_map$pct_asianage, opacity = 0.7, title = "% Asian Age",position = "bottomright")

[Scatter plot]

pct_asianage_vs_pctGOP <- ggplot(countyGIS_stat, aes(pct_asianage, pctGOP)) + 
  geom_point(aes(alpha = pct_asianage, shape = ".")) + 
  geom_smooth(method = "lm", se = FALSE) 
  
pct_asianage_vs_pctGOP

[Regression]

# Estimate regression model
pct_asianage_reg <- lm(pctGOP ~ pct_asianage, data=countyGIS_stat)

# Display model results
pander(summary(pct_asianage_reg))
  Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.7003 0.002909 240.7 0
pct_asianage -0.03468 0.001241 -27.93 3.079e-153
Fitting linear model: pctGOP ~ pct_asianage
Observations Residual Std. Error \(R^2\) Adjusted \(R^2\)
3083 0.1441 0.2021 0.2018