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:
> 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)


This code creates three vectors, Name, ABC_political_poll_results, and CBS_political_poll_results and stores 7 elements in each vector. Name consists of character elements and ABC and CBS consist of numeric elements.
Based on the topic of this module, I also added the a line of code that compiles these vectors into a dataframe I called poll_results. I used the base R function data.frame() to achieve this, listing each of the previously name vectors as arguments.
Below my code screenshot is a screenshot of my poll_results dataframe. As you can see, each of the 3 vectors are now the three columns of my dataframe, ordered in the order that I listed them in my data.frame() function
Matloff Chapter 3-5
Things I leared:
- A R List is similar to a python dictionary: Nothing has made R lists make more sense to me that this phrase haha
- Recursive lists = lists within lists, nested lists
- data frames differ from matrices in the sense that each column has a different data objects. Ex: One column can have strings, one can have integers
Link to my GitHub: here
Leave a comment