Week 3: Data Frames
Hi everyone!
This week I learned about matrices and data frames. Matrices are collection of elements in the same data type in fixed rows and columns. An example code layout is: matrix(1:4, byrow = TRUE, nrow = 2). In this example, the numbers 1 to 4 will be organized by row in 2 rows and 2 columns.
Data frames are collection of elements that can be a variety of data types that must be in a structure with the same number of rows and columns. You can even name the rows and columns using row.names(dataframe) <- c(names) and colnames(dataframe) <- c(names). An example code layout is: data.frame(Friends = c("Mary", "Sue"), Color = c("Green", "Blue")).
For this week's assignment, I will be looking at hypothetical election results.
The data set below is based on the presidential election during 2016, where it outlined the name of the candidate, the source of the poll (ABC vs, CBS). Discuss your result in your blog. Important note, I made up this data, so this data does not reflect what really happened in the election.
> Name <- c("Jeb", “Donald”, "Ted”, “Marco” “Carly”, “Hillary”, “Berine”)
> ABC political poll results <- c(4, 62 51, 21, 2, 14, 15)
> CBS political poll results <- c(12, 75, 43, 19, 1, 21, 19)
In order to visualize this data, I will create a data frame with three columns: Name, ABC, and CBS. Something to observe is the total poll results for each candidate, so I add a column with these totals.
I was interested in the order of candidates with the most media poll votes and the absolute value of the differences between votes each candidate got by polling company.
The results in the data frame show Donald won the most votes, but also had the greatest difference in results between both media platforms. I found Donald won the most total votes (137) and Carly with the least (3). CBS shows a far greater polling result for Hillary and Jeb, though their total votes are not as high. The biases within polling results are seen by the high differences between votes for some candidates versus others. My last observation was four out of seven candidates won more votes in CBS's polling results including Jeb, Donald, Hillary, and Berine. I would conclude from this data that polling results are highly variable between media platforms.
Check this out in GitHub!
-Ramya's POV

Comments
Post a Comment