I am very new to R programming, and I have a few datasets that I'm playing around with. One of the things I'm trying to do is use ggplot to graph what percentage of the population in each state voted in the 2016 election.
The first csv file I have contains an estimate of the population of each state in 2016, and the second csv file I have contains the number of votes cast by each party in the 2016 election. I'm not sure how to attach the file here, so I will show some screenshots:
From what I understand, I can read the 2016 election votes csv file, and create a new column that contains the total votes using something like:
electionVotes$TotalVotes <- electionVotes$DemocraticCandidates + electionVotes$RepublicanCandidates + electionVotes$OtherCandidates
Once I have that, I would like to create a column where I do something like:
electionVotes$PercentVoted <- electionVotes$TotalVotes / *number of people per state*
I understand how to use ggplot to display the results, but what is confusing to me is how I can accurately use these tables with each other when one State column uses an abbreviation for the state name, like "AL", while the other one uses ".Alabama".
Any thoughts on what would be the best process to do this other than manually editing the csv file? Thank you!