These labs test and build on the material presented in the SWIRL lessons.
Scroll down or click here to check how to submit them.
a. Add 3 and 5.
b. Add 1, 3, 5, 7 and 11.
c. Subtract 675 from 3.
d. Divide 1 by 1.4.
e. Multiply 2 by 2 by 2.
f. Find 2 to the 3rd power.
a. Assign 2 to the variable
b. Add 4 and
c. Assign 10 to the variable
Table 1. Box office history for all Harry Potter movies1.
|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|
a. Create three separate variables for each of the first three movies, giving them the value of their worldwide box office take.
b. Check if the Sorcerer’s Stone made more money than the Prisoner of Azkaban.
c. How much money did all three movies make together?
Table 2. Ten random responses from the class survey. You will use this table to answer a few of the questions.
|Height||Eye Color||Shoe Size||# Siblings||Home Pop.||HP Books||HP House||Ideal Temp||Fav Color||Tea or Coffee||Pineapple on Pizza?||Roll your Tongue?||Tree or Pollen Allergy|
a. A vector from 1 to 1000, using
b. The same vector, using
c. A vector from 0 to 200 in increments of 5, using
d. A vector of 10 1s, using
c(), create a vector of the sizes of your shoe size and 4 random classmates.
c(), create a combined vector of your variables from c, d, and e, and the number 10.5.
Table 3. Word counts and book size data from The Harry Potter book series.
|Harry Potter and the Sorcerer’s Stone||76,944||17||223|
|Harry Potter and the Chamber of Secrets||85,141||18||251|
|Harry Potter and the Prisoner of Azkaban||107,253||22||317|
|Harry Potter and the Goblet of Fire||190,637||37||636|
|Harry Potter and the Order of the Phoenix||257,045||38||766|
|Harry Potter and the Half-Blood Prince||168,923||30||607|
|Harry Potter and the Deathly Hallows||198,227||37||607|
a. Create a vector of the word count from each book.
b. Create a vector of the number of chapters in each book.
c. Divide the word count of each book by the number of chapters to find the average number of words per chapter.
d. Create a basic plot of the number of words per book.
a. Create a vector of your classmate’s eye colors.
b. Check what kind of vector this is?
c. Create a vector of the number of harry potter books your classmates have read.
d. Plot this vector.
a. Generate a vector of 10 shoe sizes, three people with size 10, two of size 11, and five of size 9, using
b. Create a vector of the leap years from 1900 to 2018, using
c. Count to 10 in 2s, 5 times.
d. Make a vector of your favorite color repeated 10 times.
e. Five of your classmates like pineapple on their pizza, and five do not. Use
rep() to create a vector.
a. What is the structure of your shoe size vector?
b. Summarize the shoe size data. What is the maximum shoe size in the class?
c. How is the structure of shoe size and favorite color different?
a. What is the average class height?
b. Create a boxplot of class height.
c. What is the tallest height in the class?
d. What is the average number of harry potter books read?
e. Create a barplot of HP house.
f. Create a barplot of yes vs nos to pineapple on pizza.
x<-1 : 10
mean(x <- 1:10, FALSE)
doSomethingVeryComplicated(data = datafil1,position="here",baseline = na,title="A very long title")
simonSays <- 'It's time's to gets going, y'all!'
You will need to write R code to answer each of the questions.
Please format your answers as follows:
Copy and paste each question, commented out. This ensures that we know which answer corresponds to which question.
Write your R code answer below each question.
It should look something like this:
# LAB: Unit 1. Lab 1 # Your Name # Put your name here # 1. Add 7 and 3,456. 7 + 3456 # 2. Assign this value to an object x <- 7 + 3456
Log into Canvas.
Go to the Assignments page.
Under ‘Labs’, you should find the correct assignment.
Copy and paste your R code into the text box.
Click ‘Submit Assignment’.
You are permitted to submit your answers as many times as you like within each Unit.
Answers will be graded two or three times a week and re-opened if you submit early.
Each lab will close at its respective deadline (see Canvas).
Final grades for each lab will be computed and entered into the Canvas gradebook at the end of each Unit.