MATH1051H Fall 2020
R Assignment #2
Due date: Friday, Oct. 23rd by 5:00 pm
Read these instructions carefully. Failure to comply with these instructions will result in a deduction of
points from your grade.
How do I prepare this assignment for submission?
1. The instructions for this assignment must be completed using RStudio:
a) Create a new R Markdown document. In the file creation interface, like Assignment 1, set the
Author to your full (Blackboard registered) name and student number (e.g., Bob Jones –
0612345) and then set the Title to MATH 1051H – R Assignment 2.
MAKE SURE YOUR NAME AND STUDENT NUMBER APPEAR AS THE AUTHOR,
OR YOU WILL RECEIVE A ZERO
b) Set the Default Output Format to PDF
The assignment must be turned in digitally as a compiled PDF – any other format will not be
graded, and you will receive a zero.
2. Save your R Markdown file to a convenient location (suggested: your default directory) as a R
Markdown file (.Rmd), e.g., 1051H_R_Assign2.Rmd. This name is not important, except that it
must end in Rmd.
3. Immediately knit the file, and ensure it creates a PDF.
4. Once you are done your assignment work, copy the PDF file you have created somewhere different
(e.g., Desktop or Downloads), and rename it to Last_First_StudentNum_R_Assign2.pdf. For
example, using the above fake author, the file would be Jones_Bob_0612345_R_Assign2.pdf. This
file can then be uploaded to Blackboard for grading.
What if I work in a group?
Discussing the assignment with your friends in the class is allowed, but the version that you submit
must be entirely your own – any copying of another person’s code is a violation of Academic
Integrity. You must complete the Academic Integrity statement section on your submission. Be
aware that failure to comply with that statement will be considered cheating and will be penalized
according to Trent’s Academic Integrity policies.
When and where do I submit my completed assignment?
Completed assignments must be submitted by the due date and time for assistance. Absolutely no
late submissions will be accepted for this assignment – if you do not have it in on time, you will
receive zero.
Your assignment must be submitted using the assignment interface link provided on Blackboard. No
other delivery mechanism will be accepted.
What if my .Rmd file does not knit or some R instructions fail?
Seek out help from the professor or TAs in order to correct these issues – having some instructions
fail can be worked around by using comments, but a failure to knit the file and submit it on time will
result in a zero grade.
What about the WebWork R Assignment 2?
This study source was downloaded by 100000854433047 from [Link] on 10-18-2022 01:10:49 GMT -05:00
[Link]
The WeBWorK Assignment R Assignment 2 contains data sets and context (e.g., personal numbers)
for some questions. There is no work to be submitted on WeBWorK. The grade is irrelevant, and will
not be counted (it’s only there to make sure the link works).
Questions (each must be created as its own section, e.g., ‘##’ in R Markdown)
1. Academic Integrity
Please copy the following statement as the first question of your submission, under the heading Academic
Integrity.
I am aware that I can discuss the questions on this assignment with others.
However, sharing my files or code with another person (allowing them to copy), or
having someone share their files or code with me (copying), in any way is considered
cheating and will be penalized according to Trent’s Academic Integrity policies.
2. Comparison of Two Numerical Data Sets and Plotting
In this section, you will explore plotting and exploratory analysis on provided data. Create chunks
carefully as you need to in order to ensure the overall flow of this question and response is clean and
organized.
a) Create vectors vec1 and vec2 using the two sets of random numbers from WeBWorK R Assignment
2, Problem 1. You must use the numbers given only to you. This will be checked.
b) Construct a properly labelled histogram for each of your variables. Proper labelling means axes
labels (x and y) and a title. Display the two histograms side by side using mfrow. As there is no
context, feel free to make up the label content (we’re testing your ability to make the labels, not what
you put in them).
c) Construct boxplots of your variables (one plot with two boxplots in the graph). Again, you must
properly label this graph. This is not side-by-side boxplots using mfrow, but two boxplots inside the
same boundary box.
d) Compute any summary statistics you care to (e.g., median, mean, standard deviation), in order to
supplement the figures above for part (e) below in order to complete (e) below.
e) Write a paragraph comparing the distributions of your two variables. Support your description by the
results of (b)-(d). Consider measures of centrality, spread, and skew in your discussion.
3. Binomial Probability
In this section, you will explore the binomial distribution and compute some probabilities. This
section uses WeBWorK R Assignment 2, Questions 2 and 3. Use chunks carefully throughout this
question in order to ensure good word-code grammatical flow to your final result. Feel free to use inline R
code to make your final sentences read nicely.
a) (Simple Binomial Probabilities). Refer to Problem 2 of your WeBWorK R Assignment 2. Find
and display the required probabilities, then explain each of them in words (that is, each
calculation should be followed by a sentence that begins with something like The probability that
This study source was downloaded by 100000854433047 from [Link] on 10-18-2022 01:10:49 GMT -05:00
[Link]
the binomial random variable X with ...).
b) (Complex Binomial Probabilities). Refer to Problem 3 of your WeBWorK R Assignment 2. Find
and display the required probabilities, then explain each of them in words, as you did in part (a).
4. Plotting Binomial Distributions
In this section, you will explore graphical representations of the binomial distribution using bar
charts. We have not covered bar charts in workshop or class, but the syntax is almost identical to
histograms and boxplots, so with careful reading of this question, you should be able to work through the
tricky bits.
a) Create a new chunk, and name it.
b) Consider a binomial distribution with n = 20 and probability of success p = 0.4. Create the vector
of probabilities P[X = x] for x = 0, 1, …, 19, 20, and give it a sensible name.
c) The function to create a barplot is barplot(), and the key arguments are height and [Link],
both vectors – the first (height) generates the height of the bar, while the second ([Link]) puts the
label. Use this function and your knowledge of how the binomial distribution works to make a clear,
organized plot of the discrete probability mass function P[X = x] for the above parameters (i.e., use the
result of part (b)). Ensure you use the axes appropriately, label them, and provide the reader with all
information needed to understand the purpose of the plot (including the parameters!).
d) Using the data from (c), answer the following questions using vector subsetting:
1) P[X = 4]
2) P[X = 19]
3) P[X in {12, 13, 14}]
4) P[X <= 5]
5) P[X > 15]
NOTE: you must use vector subsetting and the results of (b) to compute these (possibly with the
additional use of the sum function) – if you use fresh computations of dbinom or pbinom, you will not
receive any credit.
This study source was downloaded by 100000854433047 from [Link] on 10-18-2022 01:10:49 GMT -05:00
[Link]
Powered by TCPDF ([Link])