FES 720 Introduction to R

LAB: Basic Building Blocks

This is the lab associated with the lecture and lesson on Basic Building Blocks in R.

Please upload your final completed lab on the Assignments page in Canvas.

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!

Harry Potter Movies

In this lab, we will work with data from the Harry Potter series of moving pictures.

Table 1. Box office history for all Harry Potter movies.

Release Date Movie Production Budget Domestic Opening Weekend Domestic Box Office Worldwide Box Office
Nov 16, 2001 Harry Potter and the Sorcerer’s Stone $125,000,000 $90,294,621 $317,575,550 $974,755,371
Nov 15, 2002 Harry Potter and the Chamber of Secrets $100,000,000 $88,357,488 $261,987,880 $878,979,634
Jun 4, 2004 Harry Potter and the Prisoner of Azkaban $130,000,000 $93,687,367 $249,538,952 $796,688,549
Nov 18, 2005 Harry Potter and the Goblet of Fire $150,000,000 $102,685,961 $290,013,036 $896,911,078
Jul 11, 2007 Harry Potter and the Order of the Phoenix $150,000,000 $77,108,414 $292,004,738 $942,943,935
Jul 15, 2009 Harry Potter and the Half-Blood Prince $250,000,000 $77,835,727 $301,959,197 $935,083,686
Nov 19, 2010 Harry Potter and the Deathly Hallows: Part I $125,000,000 $125,017,372 $295,983,305 $960,283,305
Jul 15, 2011 Harry Potter and the Deathly Hallows: Part II $125,000,000 $169,189,427 $381,011,219 $1,341,511,219
Nov 18, 2016 Fantastic Beasts and Where to Find Them $180,000,000 $74,403,387 $234,037,575 $803,798,342

Source: http://www.the-numbers.com/movies/franchise/Harry-Potter#tab=summary


  1. Enter the production budget for the first movie.

  2. Assign this value to an object.

  3. Create a named vector of the years the movies were released.

  4. Create a named vector of the production budget for each movie.

  5. Create a named vector of the worldwide box office takings for each movie.

  6. How much income did each movie take in the worldwide box office (i.e., over and above the production budget)?

  7. How many times the production budget did each movie take in the domestic box office?

How to write up your answers

You will need to write R code to answer each of the questions.

Please format your answers as follows:

It should look something like this:

# LAB: Basic Building Blocks
# Simon Queenborough

# 1. What year was the first Harry Potter movie released?

# 2. Assign this value to an object
x <- 2001

How to submit your answers

You are permitted to submit your answers as many times as you like within 2 weeks.

Answers will be graded two or three times a week and re-opened if you do not score 100%.

Each lab will close after 2 weeks and final grades for that lab computed and entered into the Canvas gradebook.

To submit your answers on Canvas

  1. Log into Canvas.

  2. Go to the Assignments page.

  3. Under ‘Labs’, you should find the Basic Building Blocks assignment.

  4. Copy and paste your R code into the text box.

  5. Click ‘Submit Assignment’.

Updated 2017-09-07