MATH 208 Midterm Exam October 18th, 2019
Answer all questions on the ANSWER sheet. DO NOT WRITE ANSWERS ON THIS PAGE. Total
marks for this exam are equal to 100.
Copyright By PowCoder代写 加微信 powcoder
Question 1 [50 points]
(a) [15 pts] Consider code chunk Q1 and give the resulting output from the following R commands (or the
resulting error if one is produced):
(i) on_pop5[[2]][3]
(ii) on_pop5[2][[3]]
(iii) mode(on_pop5[[1]][c(4:5)])
(b) [15 pts] Consider code chunk Q1 and answer the following multiple choice questions (please list all that apply
for each question):
(i) Which of the following commands returns the result “Ottawa”?
A.`on_pop5$City[2]`
B.`on_pop5[[“City”]][2]`
C.`on_pop5[c(1,2)]`
D.`on_pop5[[c(1,2)]]`
(ii) The class of the object returned by on_pop5[2] is a
A. Atomic vector
C. data.frame
(iii) The class of the object returned by on_pop5[[2]] is a
A. Atomic vector
C. Logical vector
(c) [20 pts] Consider code chunk Q1 for the following questions and answer the following multiple choice questions
(please list all that apply):
(i) [10 pts] Write a line of code that will create and assign the tibble ontario_only used to create the
plot in Figure 1.
(ii) [5 pts] Write a line of code that will print the tibble row from can_pop10 which contains the data for
(iii) [5 pts] Which of the following commands yields the result below? Please list all that apply.
# A tibble: 2 x 2
City Population
1 Edmonton 932546
2 Calgary 1239220
A. `can_pop10$AB`
B. `can_pop10[3][[1]] %>% arrange(City)`
C. `can_pop10$AB %>% arrange(Population)`
MATH 208 Midterm Exam October 18th, 2019
Question 2 [50 pts]
(a) [20 marks] Which of the following plots could be properly used to assess the association between two
quantitative characteristics (assume that you cannot transform the values)? Please list all that apply.
A. Scatterplot
B. 2d barplot
C. Mosaic plot
D. 2d histogram
E. 2d density (or contour) plot
F. Pie chart
G. Line chart
H. Treemap
I. Stacked barplot
J. Boxplot
Answer the parts (b) and (c) below based on a simulated dataset of final grades (marks_tbl). The data include
the final numerical grade for the course, the corresponding letter grade (under the McGill rubric), and whether a
student had taken the pre-requisite courses. Code chunk Q2 gives a description of the data.
(b) [15 marks] Figure 2 shows two different panels plotting the student final numerical grades by the level of the
pre-requisites variable.
(i) [5 marks] Identify the type of plot used in each panel (the name, not the R function).
(ii) [5 marks] Which panel do you feel best allows you to compare the distribution of final grades in the two
groups? Explain your answer in 3 sentences or fewer.
(iii) [5 marks] Based on these plots, do you feel that there is visual evidence that students who take the
pre-requisite generally perform better in the course? Explain your answer in 3 sentences or fewer.
(c) [15 marks] Figure 3 shows two different panels plotting the student final letter grades by the level of the
pre-requisites variable. Note that the color scale for Panel (c) is not the same as in Panel (d), but the mapping
should be obvious from the plot.
(i) [5 marks] Identify the type of plot used in each panel (the name, not the R function).
(ii) [5 marks] Which panel do you feel best allows you to compare the distribution of final grades in the
two groups? Explain your answer in 3 sentences or fewer. Hint: Note the two panels are quite similar,
except in one respect.
(iii) [5 marks] Based on these plots, do you feel that there is visual evidence that students who take the
pre-requisite generally get higher letter grades? Explain your answer in 2 sentences or fewer.
MATH 208 Midterm Exam October 18th, 2019
R plots and output
Code chunk Q1
on_pop5 <- list(
City=c("Toronto","Ottawa","Mississauga","Brampton","Hamilton"),
Population=c(2731571,934243,721599,593638,536917)
can_pop10 <- list(
ON = tibble(City=c("Toronto","Ottawa","Mississauga","Brampton","Hamilton"),
Population=c(2731571,934243,721599,593638,536917)),
QC = tibble(City=c("Montreal"), Population=c(1704694)),
AB = tibble(City=c("Calgary","Edmonton"),
Population=c(1239220,932546)),
MB = tibble(City="Winnipeg",Population=c(705224)),
BC = tibble(City="Vancouver",Population=c(631486)))
ggplot(ontario_only,aes(x=City,y=Population,fill=City)) +
geom_bar(stat="identity") + scale_fill_grey() + theme_bw()
Hamilton Brampton Mississauga Ottawa Toronto
Mississauga
Figure 1: Ontario’s Five Largest Municipalities
Code chunk Q2
glimpse(marks_tbl)
Observations: 120
Variables: 3
$ Final_Grade
$ Letter_Grade
$ Taken_Prereq
MATH 208 Midterm Exam October 18th, 2019
0 25 50 75 100 0 25 50 75 100
Final Grade
t Taken_Prereq
0 25 50 75 100
Taken Prereq
Taken_Prereq
Figure 2: Numerical grade distribution vs. Pre-requisite status
F D C C+ B− B B+ A− A
Letter Grade
Figure 3: Letter grade distribution vs. Pre-requisite status
Question 1 [50 points]
Question 2 [50 pts]
R plots and output
Code chunk Q1
Code chunk Q2
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com