Election Data Frame

Errors in the original data set: a missing comma between Marco and Carly in Name, I fixed the spelling of Berine to Bernie, a missing comma between 62 and 51 in ABC, quotation marks around names had to be changed to " ", the variable names for ABC and CBS political poll results had spaces, which I changed to _.


After fixing all the errors in the data set, I used the three variables Name, ABC_political_poll_results,  and CBS_political_poll_results to create the data frame. Since the data set is based on the 2016 presidential election, I named the data frame election_2016. Here is my corrected code in R:


Name <- c("Jeb", "Donald", "Ted", "Marco", "Carly", "Hillary", "Bernie")

ABC_political_poll_results <- c(4, 62, 51, 21, 2, 14, 15)

CBS_political_poll_results <- c(12, 75, 43, 19, 1, 21, 19) 

election_2016 <- data.frame(Name, ABC_political_poll_results, CBS_political_poll_results)

election_2016


After running the data frame, my result was:









From the data frame, I can see that the poll results for ABC and CBS differ for every candidate, with some candidates having a bigger difference in their numbers than others. Jeb, Donald, Hillary, and Bernie have higher outcomes on CBS, while Ted, Marco, and Carly have higher results on ABC. Even though the winner is the same in both sources, Donald, we can see that some of the other candidates have different orders between the two. These results just show that sources like ABC and CBS can give different results on an important election like this, so it is recommended to not get your information from only one place.


Comments

Popular posts from this blog

myMean Error and Correction

Doing Math on Matrices