2023-03-29

Summary

There are many tools out there - and they are in your face around every presidential election - that allow the user to play around with the United States of America electoral system, the Electoral College.

Rather than reinvent the wheel, the following tool is instead an unrealistic but hopefully visually appealing and enlightening tool to show what it might look like for a candidate to get a certain number of electoral college (EC) votes.

URL here: https://dwhitwood.shinyapps.io/jshcourseraddp4/

Explanation / Instructions

This shiny app has a slider that goes from 0 to 538, which is the range from no EC votes to all of them. As you move the slider, underneath the hood the code is selecting the largest states by population that you could win under that total (of course different approaches could be taken here!) then at the end makes sure to grab a smaller state to ensure that the total doesn’t go more than 2 EC votes above your target.

When you have 0 votes or near 538, the map will not be interesting, all are either won or lost to the hypothetical candidate. As the slider moves you will see the selection of states change, often painting a dramatically different map for a small move of the needle.

Examples

Let’s say you are targeting 99 electoral votes. I have created tables mapping the states to their votes, and the algorithm in this instance chose California, Texas, and Utah:

chosenStates <- c("California","Texas","Utah")
votes <- df$ECVotes[df$States %in% chosenStates]
data.frame("State" = c(chosenStates, "Total"),
           "Votes" = c(votes,sum(votes)))
>>        State Votes
>> 1 California    55
>> 2      Texas    38
>> 3       Utah     6
>> 4      Total    99

Conclusion

I hope you will tinker with the shiny app and find some entertainment. Your results will not only vary from what I have in the last slide, but they’ll vary for nearly any value of an EC target you select.

Thank you for viewing my presentation.