Professional Documents
Culture Documents
MTH3409
COMPUTATIONAL
STATISTICS
2) Using a while loop, write a function in R that consists of two arguments. The first argument
is a numeric vector, and the second argument is a number. This function will print out all the
elements in the numeric vector and stop once an element is larger than the number of the
second argument. [5 marks]
3) Write a double for loop that prints out the following output: [5 marks]
a) Create a new data frame from the imported data by selecting rows 5473 to 5968.
[2 marks]
b) From the data frame in (a), create a new data frame by selecting these variables:
state, cases_new, cases_child, cases_adolescent, cases_adult, and
cases_elderly. Name the data frame as mydata. [2 marks]
c) Based on mydata, write an R script that will print out the cases_new elements that
≥ 300. [2 marks]
d) Based on mydata, write a loop that will print out the cases_new elements that ≥ 300.
Check your answer with the results in (c). [3 marks]
6) Prepare a video presentation explaining how to write the R code and summarizing your
findings for questions 4 and 5. [Marks based on rubric]