Professional Documents
Culture Documents
PENILAIAN 1
Assessment 1
Semester Pertama Sesi 2022/2023
(First Semester of 2022/2023)
TARIKH (DATE) : 15 NOVEMBER 2022 MASA (TIME) : 10.15 – 11.15 PAGI (AM)
* This is an open book evaluation. You may access notes and textbook. However, direct or
indirect interaction with other human beings are prohibited with regards to answering the
questions. Suspicions of foul play (cheating) will result in extreme marks reduction (you
will get 0. No negotiation).
Nama (Name) :
X = {22.5, 31.9, 21.3, 37.2, 40.0, 37.6, 32.5, 29.9, 27.5, 38.3}
Y = {48.2, 48.2, 44.6, 55.6, 50.1, 53.3, 53.1, 49.4, 52.5, 51.2}
d) Compute the mean and standard deviation for both vectors X and Y.
[4 marks]
2
e) Create a 2 × 10 matrix where Y is at the first column and X is at the second column.
Name the matrix as matrix1.
[2 marks]
f) Sort the second column of matrix1 in ascending order. Next, transpose matrix1 and
multiply it by 10.
[4 marks]
3
2. Consider the following vector variables that have been defined in R:
Month<-factor(2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6)
Ozone<-c(1, 19, 7, 89, 49, 14, 20, 7, 36, 79, 39, NA, 66, NA, NA, 78, 82, 21, NA, 84)
Wind<-c(10.3, 12.6, 6.9, 8.6, 9.7, 6.9, 6.3, 7.4, 10.3, 6.3, 14.9, 13.8, 6.3, 10.3, NA, 6.9,
10.9, 8.0, 10.9, 8.6)
Temp<-c(90, 61, 77, 79, 82, 92, 94, 82, 81, 76, 74, 69, 76, 81, 88, 84, 75, 84, NA, 86)
b) Remove all rows with NAs in metdata and name the data frame metdata1.
[2 marks]
c) Assign the Month variable in metdata1 with the following factor labels:
[4 marks]
Month Lable of Month
2 Feb
3 Mar
4 Apr
5 May
6 June
4
d) Compute the median and range of all numeric variables in metdata1 by Month.
[4 marks]
5
3. Write the R coding using for loop that prints out the number from 10 to 50 with increment
1, but it skips any number which is the factor of 7.
[5 marks]