FES 720 Introduction to R

LAB: Missing Values

This is the lab associated with the lecture and lesson on Missing Values/Data 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!


Here are some of the data from the Harry Potter movies data we have been using, as three vectors.

“Unfortunately”, as I was making these, the dog ate some of them … resulting in some missing data …

You can read these into R by copying and pasting the three lines into the Console.

year <- c(2001, 2002, 2004, 2005, 2007, 2009, 2010, 2011, 2016)

prod_budget <- c(125000000, NA, 130000000, 150000000, NA, 250000000, 125000000, 125000000, 180000000)

ww_boxoffice <- c(974755371, 878979634, NA, 896911078, NA, 935083686, 960283305, 1341511219, 803798342)

Questions

  1. Create a vector identifying Which films are missing their year of release?

  2. Which films are missing their production budget?

  3. Which films are missing their worldwide box office?

  4. Use mean() to calculate the mean production budget for all years that there are data.

  5. Use mean() to calculate the mean worldwide box office for all years that there are data.

  6. Calculate the return on investment for each film.

  7. Calculate the mean return in investment over all films.


How to write up your answers

Please check the help page for a reminder, if you need to.