This is the lab associated with the lecture and lesson on Lists in R.
Please upload your final completed lab on the Assignments page in Canvas, as per the instructions below.
You are welcome and expected to ask for help from the instructors if you get stuck: Please also come to the R Bootcamp on Friday—there is coffee and snacks!
The output of many functions, especially statistical tests, is a list.
Run a t-test on two vectors (we will cover statistial tests after October break, so don’t worry about the details now). We have assigned it to a new object ‘m’.
m <- t.test(1:10, 10:1)
Is it a list? Check with is.list()
Look at the structure of ‘m’.
Extract the p-value
Extract the estimated mean of x.
Think back to the lab on Vectors …
Create an object containing the text string “Harry Potter and the”. Call this string hpat
.
Create a vector with the specific title section for each movie 1–8 (e.g., “Sorcerer’s Stone” for movie 1), called hp_titles
.
Combine the vectors hpat
and hp_titles
to create a vector of 8 elements for the full titles of the first 8 movies. Call this vector hp_movies
Put these three objects into a list.
Read in the Harry Potter Movie data
dat_hp <- read.table("http://www.simonqueenborough.info/R/data/harry-potter-movies-numeric.txt",
sep = '\t', header = TRUE)
Please check the help page for a reminder, if you need to.
Updated: 2017-10-08