Starting from:

$25

STAT240  Lab 01 SOLVED

STAT240 
Lab 01
Problem 1: Loading data
a) Write an R script to do the following:
1) Assign your student number to a variable called a.
2) Print out the variable a.
3) Update the variable a by setting a to the value of a modulo 9
(a modulo b is the remainder after integer division of a by b
and the binary operator to do modulo in R is %% for example
print(7920 %% 9)).
4) Update the variable a by adding 1 to a.
5) Print out the updated variable a.
Provide a screenshot of your R Studio session including the script you
wrote in the editor, and the output of the script in the console. To take
a screenshot in Windows, make sure R Studio is the active window and
then press Alt+PrtSc.
(2 points)
b) The archive containing this lab also contains 10 datasets listed in the
excel document datasets.xlsx. Each dataset has two files: One containing the data itself, and the other containing a description of the data.
Each of these 10 datasets have been assigned identification numbers
(dataset IDs). The first column of datasets.xlsx is the dataset ID. You
will analyze the dataset with ID given by your student number modulo
9 plus one (we will call this the dataset with ID ‘a’). Write an R script
to do the following:
1) Load the data for the dataset with ID a using an appropriate call
to read.table or to read.csv.
1 of 2
STAT240 Spring 2022 SFU Due January 20th 5 5PM PST
2) Compute the mean of the d-th column of the dataset, and assign
a variable to this mean. Here d is given by the column number
specified in the column Column in datasets.xlsx for the dataset
with ID a.
3) Compute the median of that same column (and assign a variable
to it; and for the remaining 3 computations, assign the result of
the computation to a variable).
4) Compute the standard deviation of that column.
5) Compute the minimum of that column.
6) Compute the maximum of that column.
7) Print out each of the 5 summary statistics computed above to 3
decimal places. Use the variables you assigned in the previous
steps in the code used to print (don’t just ‘hard code’ the output
by doing something like print("3.142")). Don’t worry about
leading line number indicators (like ‘[1]’) in the output.
Make an R Markdown file with title Lab01 and include your student
ID below the title. Make a section called Problem 1b and write a
sentence or two about what you did. Also give the name of the dth column of the dataset you analyzed (according to the information
file corresponding to the dataset you analyzed). Here d is the same
d that was used in the steps above. Include the script you wrote for
this problem in the markdown file, and also the output of the script.
Compile your markdown file to html, and then convert the html to
a pdf (by opening it in the web browser and printing to a pdf file).
Provide the pdf.
(8 points)
2 of 2

More products