You are on page 1of 1

Statistical data analysis, Assignment 1

Name: ID:

Problem 1. Generate an arithmetic sequence consisting of 100 terms with a common dif-
ference of 2, assigned to variable ’Seq’ in your R console.
(i) Calculate the mean of Seq, rounding it to the second decimal place if your answer is not
an integer.
(ii) Calculate the standard deviation of Seq, rounding it to the second decimal place if your
answer is not an integer.
(iii) Calculate the median of Seq and determine if it is equal to the result from (i). Please
use logical operators in R to answer, expressing your answer as TRUE or FALSE.
 
1 2 1
Problem 2. Create a matrix A = 2 4 6.
  1 3 3
1 1
(i) For B = 2 −3, calculate AB.

4 −1
(ii) Calculate A−1 , and det (A−1 ).
(iii) From (i), report (AB)1,2 and (AB)3,1 .
(iv) From (ii), assign the value 3 to the element in the [3,2] position of A−1 , denoted as C,
then calculate CB.

Problem 3. Calculate sin 199


200
π +cos−1 0.8534+log10 (3π +etan 9.88π ), rounding it to 4 decimal
place.

Problem 4. Access the Iris dataset by simply typing iris in your R console. Notice that
this dataset is automatically available in R as part of its base datasets.
(i) List the variables and classify them as categorical or numerical.
(ii) Determine the number of observations in the dataset.
(iii) Compute the mean for Sepal.Length, Sepal.Width, Petal.Length, and Petal.Width, re-
spectively.

Problem 5. Read the sleep.csv file into R.


Calculate the mean of the ’extra’ sleep (in hours) for each group within the dataset.

Problem 6. Exercises: 1.35, 1.38, and 1.43 from textbook OpenIntro Statistics, 2019,
p.36.

You might also like