Professional Documents
Culture Documents
Sda HW1
Sda HW1
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 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 6. Exercises: 1.35, 1.38, and 1.43 from textbook OpenIntro Statistics, 2019,
p.36.