Fill This Form To Receive Instant Help
Homework answers / question archive / Final Project - Fall 2020 Due Friday December 18 by 11 pm You can do this assignment in R
Due Friday December 18 by 11 pm
Submit a single .R file. I will run your functions in R studio.
There is a Final Project folder on eLC. In this folder, there is a file called USElection2020-NYT-Results- master.zip. This is a zip file containing election returns for the 2020 election. Within the data folder there are a series of folders with names consisting of dates and times. Within each folder is a spreadsheet that contains the county-level vote totals as of the time that the spreadsheet was produced. For example, “2020-11-10 00-08-35” contains vote totals updated at 8:35 AM on November
FIPS: A unique geographic identifier for each county or state. Used for identifying counties and/or states.
State: State name.
Votes: total votes counted as of the update.
absentee: total absentee (mail-in) votes counted as of the update.
results_trumpd, results_bidenj: total votes counted for Trump and Biden. results_trumpd, results_bidenj: total absentee votes counted for Trump and Biden. (Note that the total vote counts are the sum of absentee and in-person votes)
last_updated: the date and time that the vote count was last updated for that county. This will be some point before the date/time that the data file was generated.
You should make a function of the form
This function should produce plots showing the vote totals for the given days.
whichday: the day after the election for which plots should be produced. A separate plot should be made for each day and the plots arranged in a grid. For example, whichday=5 means that plots should be produced for 5 days after election day (i.e. November 8).
electoral: Whether electoral votes or popular votes should be plotted. If electoral=T, then electoral votes should be plotted. If electoral=F, then popular votes should be plotted. The default should be electoral=F.
vote_type: This has possible values of “total”, “absentee”, or “in-person”. This indicates the type of vote that should be counted. The default should be “total”. This does not have any meaning if electoral=T. That is, electoral votes do not depend on the vote type.
region: The region of the country to show. Can either be list of states or a region as specified in the
usmap function (see below). If this argument is not specified, then it should show the whole country.
Here is example output
|
plot_election_results(5, electoral=T, vote_type=”absentee”)
Notes: