Assignment 2022 Combined.
Assignment 2022 Combined.
July 2022
Assignment 1
1. Which of the following command is used to get help on the mean function?
a. "?mean"
b. ?’mean’
c. ?mean
d. mean?
a. help.search()
b. start.help()
c. search.help()
d. help.start()
a. demons(lm.glm)
b. Demo(‘lm.glm’)
c. demo(lm.glm)
d. demo(!lm.glm)
4. Which of the function provides the help on finding an example on the function
var?
a. example("var")
b. ex(var)
c. show.example(var)
d. show.example("var")
1
5. Which of the function does not provide the help in finding the contents of the
library bayesm?
a. library(help=bayesm)
b. library(help="bayesm")
c. library(help='bayesm')
d. library(help=bayesm?)
a. install.packages(bayesm)
b. install.packages("bayesm")
c. install.packages(bayesm?)
d. install.package("bayesm")
7*. Which of the following command is used to update the package bayesm?
a. update.packages(bayesm)
b. update.packages("bayesm")
c. update.packages(bayesm?)
d. update.package("bayesm")
a. detache(package:bayesm, unload=TRUE)
b. detached("package:bayesm ", unload=TRUE)
c. Detach("package:bayesm", unload=FALSE)
d. detach("package:bayesm", unload=TRUE)
2
9. Which of the following command removes the package bayesm?
a. remove.packages(bayesm)
b. remove.packages("bayesm")
c. remove.packages(bayesm?)
d. remove.package("bayesm")
10. Which of the following command provides the description of the package
cluster?
a. packagedescription("cluster")
b. packageDescribe("cluster")
c. PackageDescription("cluster")
d. packageDescription("cluster")
3
MOOC Course – Foundations of R Software
Answers of Assignment 1
1. c
2. d
3. c
4. a
5. d
6. b
7. b
8. d
9. b
10. d
4
MOOC Course - Foundations of R Software
July 2022
Assignment 2
1. Which of the following command is used to search the web for information and
answers about keyword mean ?
a. RsiteSearch("mean")
b. RSiteSearch(mean)
c. RSiteSearch("mean")
d. rsitesearch("mean")
2. Which of the following is the correct matching of the commands in column A and
the outputs in Column B when executed in R console where x = 20 and y = "20"?
Column A Column B
(1) is.character(x) (i) TRUE
(2) is.character(y) (ii) FALSE
a. (1)-(ii), (2)-(i)
b. (1)-(i), (2)-(ii)
c. (1)-(i), (2)-(i)
d. (1)-(ii), (2)-(ii)
1
3. Which of the following is the correct matching of the commands in column A and
the outputs in Column B when executed in R console where x = 20 and y = "20"?
Column A Column B
(1) is.numeric(x) (i) TRUE
(2) is.numeric(y) (ii) FALSE
a. (1)-(ii), (2)-(i)
b. (1)-(i), (2)-(ii)
c. (1)-(i), (2)-(i)
d. (1)-(ii), (2)-(ii)
4. Which of the following is the correct matching of the commands in column A and
the outputs in Column B when executed in R console where x = 20 and y = "20"?
Column A Column B
(1) mode(x) (i) numeric
(2) mode(y) (ii) character
a. (1)-(ii), (2)-(i)
b. (1)-(i), (2)-(ii)
c. (1)-(i), (2)-(i)
d. (1)-(ii), (2)-(ii)
2
5. Which of the following is the correct matching of the commands in column A and
the outputs in Column B when executed in R console where x = 20 and y = "20"?
Column A Column B
(1) storage.mode(x) (i) double
(2) storage.mode(y) (ii) character
a. (1)-(ii), (2)-(i)
b. (1)-(i), (2)-(ii)
c. (1)-(i), (2)-(i)
d. (1)-(ii), (2)-(ii)
6. Which of the following is the correct matching of the commands in column A and the
outputs in Column B when executed in R console where x = 20 and y = 20 + Inf?
Column A Column B
(1) is.finite(x) (i) TRUE
(2) is.infinite(y) (ii) FALSE
a. (1)-(ii), (2)-(i)
b. (1)-(i), (2)-(ii)
c. (1)-(i), (2)-(i)
d. (1)-(ii), (2)-(ii)
3
7. What will be the outcome of following commands when executed over the R
console
x=43
y=x^3
z=y^2+x^4
z
a. 6231634898
b. 6321364898
c. 6324781850
d. 6342718850
5-3+4/6*7-3^3*4-7/6*2-3**3/2+6-7+2 ?
a. -107.1667
b. -116.1667
c. -125.5
d. 116.1667
15/(-5)*2+8^(-3)/(65/32)-4**3+4-81^(-1/4)+2^(-4**3) ?
a. -66.33237
b. -77.33237
c. -65.32148
d. None of these
4
10. Which one of the following is the correct outcome of the command
c(12,13,15,17)/10 + c(1.2,1.3,1.5,1.7)*10?
a. 24 26 30 34
b. 2.4 2.6 3.0 3.4
c. 13.2 14.3 16.5 18.7
d. None of these
Answers of Assignment 2
1. c
2. a
3. b
4. b
5. b
6. c
7. c
8. b
9. a
10. c
5
MOOC Course - Foundations of R Software
July 2022
Assignment 3
c(9,16,6,20)/c(3,4)+ c(4,2,4,2)^c(2,3)+c(2,4,8,6)/c(2,2)-
c(3,8,2,4)*c(3,1) ?
a. 11 6 16 12
b. 9 2 8 6
c. -23 -14 -24 -10
d. None of these
1
3. Which one of the following command will give a result without a warning?
sqrt(c(2,6,7,8)*c(4,2,2,4)+ c(2,4,2,4)*c(-2,2)+
c(1,2,4,4)**c(9,2,4,1))?
c(1,2,1,2)*-c(1,2,-1,-2)**c(-1,-2,1,2)*-c(1,2,-1,-2)?
a. 1 1 1 16
b. 1 1 1 -16
c. -1 -16 1 16
d. -1 -1 -1 -16
2
6. Which one of the following is the correct outcome of the command
c(5,6,7,8)%/%4- c(64,64,24,24)%/%c(4,3,5,7)+
c(153,646,817,788)%%c(71, 63) ?
a. 4 4 33 31
b. -4 -4 -33 -31
c. -4 -4 33 31
d. 4 4 -33 -31
min(c(98,88,44,76)**c(-2,3))/min(c(49,44,22,38)^c(-2,-3)) -
prod(c(1,2,1,2)^c(1,2))/max(c(9,4,4,9,26)*min(c(4,3,2,6))
)+max(c(22,23,24,25)^c(2,3)) ?
a. -16680439
b. 16680439
c. 15633.56
d. None of these
3
9. Which one of the following is the correct outcome of the command
floor(c(5,6,7,8)^c(2,3))- ceiling(c(5,6,7,8)^c(2,3))+
ceiling(c(2,3,4,5)^-c(1,-2)) - round(c(5,6,7,8)^c(2,3)) +
floor(c(5,6,7,8)^c(2,3))?
a. 51 441 99 1049
b. 1 9 1 25
c. -1 -9 -1 -25
d. None of these
10. Which one of the following is the correct outcome of the command
ceiling(c(4,8,4,5)^-c(3,9) + sqrt(c(36,16,81,64)**c(2,3))*
sqrt(c(2,3,4,5)^-c(1,2)) + round(c(4,7,8,9)*round(c(7,9))))
?
a. 54 85 97 184
b. -2 -41 -15 22
c. 3 42 16 -21
d. None of these
11. Which one of the following is the correct outcome of the command
ceiling(prod(c(2,3,8,9))- sum(c(2,22,23,24,151))) -
floor(prod(c(2,3,8,9))+ round(c(2,22,23,24,151)))?
4
12. Which one of the following is the value of X2 when the following commands are
executed over the R console?
X1 = c(23,25,18,24)
X2 = sqrt(X1^2)+X1*6/X1^2-X1**(1/2)+abs(X1)
13. Which one of the following is the correct outcome of the command
c(21,22,24,34)^c(-3,-2,2,3)/c(4,3,2,1) +
c(2,4,1,6)%/%c(3,4)*c(2,5,3,6)+
max(c(20,140,114,215)^c(1,2))/min(c(6,2,7,15)^c(2,2))?
5
14. Which one of the following is the correct command to obtain the following matrix?
21 24 27
x = 22 25 28
23 26 29
a. x=matrix(21:29,3,3,byrow=T)
b. x=mat(21:29,3,3, byrow=T)
c. x=matrix(21:29,3,3,byrow=F)
d. x=mat(21:29,3,3,byrow=F)
15. Which one of the following is the correct command to obtain the following matrix?
15 11 17
z =
8 19 12
6
16. Which one of the following is the correct command to obtain the third column and
first row of the following matrix?
10 20 30
x = 40 50 60
70 80 90
17. Which one of the following is the correct outcome of the command X[3,2] for
the matrix constituted by the command X=matrix(61:69,3,3,byrow=F)?
a. 63
b. 66
c. 67
d. 68
18. Which one of the following is the correct outcome of the commands dim(x) and
dim(y) for the matrices obtained by x=matrix(101:150,25,2,byrow=T)
and y=matrix(201:250,25,2,byrow=F) ?
a. 25 2 and 2 25 respectively.
b. 2 25 and 25 2 respectively.
c. 2 25 and 2 25 respectively.
d. 25 2 and 25 2 respectively.
7
MOOC Course - Foundations of R Software
Answers of Assignment 3
1. b
2. a
3. b
4. a
5. b
6. c
7. c
8. b
9. b
10. a
11. c
12. a
13. c
14. c
15. a
16. c
17. b
18. d
8
MOOC Course - Foundations of R Software
July 2022
Assignment 4
1. Which one of the following is the correct outcome of the command rowSums(X)
for the matrix constituted by the command X=matrix(61:69,3,3,byrow=F)?
a. 69 65 61
b. 186 195 204
c. 61 65 69
d. 192 195 198
2. Which one of the following is the correct outcome of the command colSums(X)
for the matrix constituted by the command X=matrix(61:69,3,3,byrow=F)?
a. 69 65 61
b. 186 195 204
c. 61 65 69
d. 192 195 198
3. Which one of the following is the correct outcome of the command rowMeans(X)
for the matrix constituted by the command X=matrix(61:69,3,3,byrow=F)?
a. 64 65 66
b. 62 65 68
c. 186 195 204
d. 192 195 198
1
4. Which one of the following is the correct outcome of the command colMeans(X)
for the matrix constituted by the command X=matrix(61:69,3,3,byrow=F)?
a. 64 65 66
b. 62 65 68
c. 186 195 204
d. 192 195 198
5. Which one of the following is the correct outcome matrix of the command
5 5
a. x =
0 5
0 5
b. x =
5 0
5 5
c. x=
5 5
5 0
d. x=
0 5
6. Which one of the following is the correct outcome of the command t(x) for
2
x=matrix(nrow=3, ncol=2, data=30:35, byrow=T) ?
a.
[,1] [,2] [,3]
[1,] 30 32 34
[2,] 31 33 35
b.
[,1] [,2]
[1,] 30 31
[2,] 32 33
[3,] 34 35
c.
[,1] [,2]
[1,] 30 33
[2,] 31 34
[3,] 32 35
d.
[,1] [,2] [,3]
[1,] 30 31 32
[2,] 33 34 35
7. Which one of the following is the correct command to obtain the multiplication of
two square matrices x and y of the same order?
a. x**y
b. x*%*y
c. x%*%y
d. x%**%y
3
8. Which one of the following is the correct command to obtain the multiplication of
4 7 12 13
two matrices x= and y = along with its correct answer?
8 2 16 11
a. x*y
and its correct answer is
[,1] [,2]
[1,] 48 128
[2,] 91 22
b. x*%*y
and its correct answer is
[,1] [,2]
[1,] 48 91
[2,] 128 22
c. x%*%y
and its correct answer is
[,1] [,2]
[1,] 160 129
[2,] 128 126
d. x%%*%%y
and its correct answer is
[,1] [,2]
[1,] 160 128
[2,] 129 126
4
9. Let x= matrix(nrow=3, ncol=3, data=49:41, byrow=T) then which
one of the following is the correct outcome of 3*x ?
a.
[,1] [,2] [,3]
[1,] 147 144 141
[2,] 138 135 132
[3,] 129 126 123
b.
[,1] [,2] [,3]
[1,] 147 138 129
[2,] 144 135 126
[3,] 141 132 123
c.
[,1] [,2] [,3]
[1,] 141 132 123
[2,] 144 135 126
[3,] 147 138 129
d.
[,1] [,2] [,3]
[1,] 129 126 123
[2,] 138 135 132
[3,] 147 144 141
5
10. Which one of the following is the correct command to obtain of the addition of
4 8 12 16
two matrices x= and y = along with its correct answer?
7 2 13 11
a.
x + y
and its correct answer is
[,1] [,2]
[1,] 16 24
[2,] 20 13
b.
x %+% y
and its correct answer is
[,1] [,2]
[1,] 16 24
[2,] 20 13
c.
x %%+%% y
and its correct answer is
[,1] [,2]
[1,] 20 13
[2,] 16 24
d.
x %+%+ y
and its correct answer is
[,1] [,2]
[1,] 20 13
[2,] 16 24
6
11. Let x= matrix(nrow=4, ncol=4, data=16:31, byrow=F) then which
one of the following is the correct outcome of 2+4%*%x ?
a.
[,1] [,2] [,3] [,4]
[1,] 66 80 96 112
[2,] 68 84 100 116
[3,] 72 88 104 120
[4,] 76 92 108 124
b.
[,1] [,2] [,3] [,4]
[1,] 66 82 98 114
[2,] 70 86 102 118
[3,] 74 90 106 122
[4,] 78 94 110 126
c. Error...
d. None of these
12. Which one of the following is the correct outcome of X[3 ,] for the matrix
specified by
a. [1] 30 60 90
b. [1] 10 20 30
c. [1] 40 50 60
d. None of these
7
13. Which one of the following is the correct outcome of x[1:2,2:3] for the matrix
specified by x= matrix(nrow=4, ncol=4, data=16:31, byrow=T)?
a.
[,1] [,2]
[1,] 21 22
[2,] 17 18
b.
[,1] [,2]
[1,] 17 18
[2,] 21 22
c.
[,1] [,2]
[1,] 17 21
[2,] 18 22
d.
[,1] [,2]
[1,] 17 17
[2,] 17 17
8
20 30
14. Which one of the following is the correct command to get the matrix 50 60
80 90
from the matrix specified by
a. X[2:3, 1:3]
b. X[1:3, 2:3]
c. X[1:1, 2:2, 3:3]
d. X[3:3, 2:2, 1:1]
9
15. Which one of the following is the correct output of the command cbind(x,y)
for the matrices specified by
a.
[,1] [,2]
[1,] 30 31
[2,] 32 33
[3,] 34 35
[4,] 10 20
[5,] 30 40
[6,] 50 60
b.
c.
d.
[,1] [,2]
[1,] 10 20
[2,] 30 40
[3,] 50 60
[4,] 30 31
[5,] 32 33
[6,] 34 35
10
16. Which one of the following is the correct output of the command rbind(y,x)
for the matrices specified by
a.
[,1] [,2]
[1,] 30 31
[2,] 32 33
[3,] 34 35
[4,] 10 20
[5,] 30 40
[6,] 50 60
b.
c.
d.
[,1] [,2]
[1,] 10 20
[2,] 30 40
[3,] 50 60
[4,] 30 31
[5,] 32 33
[6,] 34 35
11
13 1 12 5
4 20 14 6
17. If x = 5 3 16 7 then which one of the following is the correct
16 8 12 8
command and its outcome for obtaining the inverse of the sub-matrix of x formed by
first, second, and third rows and second, third, and fourth columns?
a.
solve(x[1:3,2:4])=
[,1] [,2] [,3]
[1,] -0.02777778 0.05555556 -0.02777778
[2,] 1.69444444 0.11111111 -1.30555556
[3,] -3.86111111 -0.27777778 3.13888889
b.
inv(x[1:3,2:4])=
[,1] [,2] [,3]
[1,] -0.02777778 0.05555556 -0.02777778
[2,] 1.69444444 0.11111111 -1.30555556
[3,] -3.86111111 -0.27777778 3.13888889
c.
inv(x[1:3,2:4])=
[,1] [,2] [,3]
[1,] -0.02777778 1.6944444 -3.8611111
[2,] 0.05555556 0.1111111 -0.2777778
[3,] -0.02777778 -1.3055556 3.1388889
d.
solve((x[1:3,2:4]))=
[,1] [,2] [,3]
[1,] -0.02777778 1.6944444 -3.8611111
[2,] 0.05555556 0.1111111 -0.2777778
12
[3,] -0.02777778 -1.3055556 3.1388889
18. Which one of the following is the correct outcome of the command
(x < 15) || (x > 12) & (x < 15) && (x > 12)||(x == 17) when
x = 13 and when x = -13 ?
19. Suppose x = 13:16 . Then which one of the following is the correct outcome
of the command
20. Suppose x = 3:18 . Then which one of the following correctly specifies the
outcome of the following statement: x[(x > 12) & (x < 17)] and x[(x >
15) | (x < 5)] ?
13
d. are the same for both as 5 6 7 8
21. Suppose x = 10:50 . Then which one of the following is the correct command
to know that which of the values in x are more than 30 and less than 40?
22 . Suppose x = 45:80 . Then which one of the following is the correct outcome
of (x > 80) && (x < 70) and (x > 80) || (x < 70) ?
23. Suppose x = 13:17 then which one of the following is the correct outcome of
a. TRUE
b. FALSE
c. 13 14 15 16 17
14
d. 17 16 15 14 13
c. TRUE
d. FALSE
c. TRUE
d. FALSE
15
MOOC Course - Foundations of R Software
Answers of Assignment 4
1. d
2. a
3. b
4. a
5. d
6. a
7. c
8. c
9. a
10. a
11. c
12. a
13. b
14. b
15. c
16. d
17. a
18. b
19. a
20. a
21. a
22. d
23. c
24. a
25. b
16
MOOC Course - Foundations of R Software
July 2022
Assignment 5
1. Suppose x is any vector as x=c(10, 80, 90, 101:200, NA) then which
one of the following is the correct outcome of the command mean(x,
na.rm=FALSE)?
a. 147.8641
b. 96.2
c. Error...
d. NA
2. Suppose x is any vector as x=c(10, 80, 90, 101:200, NA) then which
one of the following is the correct outcome of the command mean(x,
na.rm=TRUE)?
a. 147.8641
b. 96.2
c. Error...
d. NA
1
3. Suppose x is any vector as x=c(10, 80, 90, 101:200, NA) then which
one of the following is the correct outcome of the command
mean(na.omit(x))?
a. 147.8641
b. 96.2
c. Error...
d. NA
a. 12164
b. 12170
c. 526
d. 123
2
5. Which one of the following is the correct syntax to compute y for the following
function?
2 x + | x − 66 |
3/2 4
if x0
y=
3exp( x ) − x
x0
3 5/2
if
a. [1] 14 8 18 16 22 10 16
b. [1] 14 6 18 10 22 7 16
c. [1] 24 8 32 16 40 10 28
d. [1] 24 6 32 10 40 7 28
3
7. Which one of the following is the correct outcome of the command
switch(2, "UP", "MP", "J&K", "Bihar", 20, 40, 60+40)?
a. 100
b. "UP"
c. "MP"
d. 40
a. 100
b. "UP"
c. 60+40
d. 40
a. "S3"
b. "MP"
c. "J&K"
d. 100
4
10. Which one of the following is the correct outcome of the command
switch("N3", "S1"= "UP", "S2" = "MP", "S3" = "J&K", "S4" =
"Bihar", N1 = 20, N2 = 40, N3 = 60+40)?
a. "S3"
b. "MP"
c. "J&K"
d. 100
a. 60+40
b. 7
c. Error...
d. NA
5
MOOC Course - Foundations of R Software
Answers of Assignment 5
1. d
2. a
3. a
4. b
5. b
6. d
7. c
8. a
9. c
10. d
11. b
6
MOOC Course - Foundations of R Software
July 2022
Assignment 6
a.
[1] 121
[1] 144
[1] 169
b.
[1] -23 + i2
[1] -25 + i2
[1] -27 + i2
c.
[1] 145-2i
[1] 170-2i
[1] 197-2i
d.
[1] 169
[1] 144
[1] 121
1
2. Which one of the following is the correct outcome of
a.
b.
[1] 3030
[1] 4026
[1] 5220
[1] 6630
[1] 8274
c.
[1] 120
[1] 132
[1] 144
[1] 156
[1] 168
d. Error...
2
3. Which one of the following is the correct outcome of the following commands
about while loop?
y = 5
a.
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
b.
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is helpful."
c.
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."
[1] "R Course" "through NPTEL is helpful."
[1] "R Course" "through NPTEL is not helpful."
d.
3
4. Which one of the following is the correct outcome of the following while loop?
x = 20
a.
[1] 410
b.
[1] 20
c.
[1] 410
[1] 410
d.
[1] 20
[1] 20
[1] 35
[1] 35
4
5. Which one of the following is the correct specification to compute
a. y<-function{x}{sqrt(exp(x)+x^2)+x^3/2-4000}, y=3371.298
b. y<-f(x)[sqrt(exp(x)+x^2)+x^(3/2)-4000] , y=984.891
c. y<-function(x){sqrt(exp(x)+x^2)+x^3/2-4000}, y=3371.298
d. y<- function(x){sqrt(exp(x)+x^2)+x^(3/2)-4000}, y
=984.891
6. Which one of the following is the correct outcome of z(14,11) of the function spe
cified as z=function(x,y){sqrt(x^3-y^3+log(x))+log(-(5*x^-2+6*y^-
2-60))-(x^3-y^2)^(3/4)} ?
a. -4511644550
b. -324.8028
c. -2758.699
d. None of these
abs(seq(-30,-35))?
a. [1] 30 31 32 33 34 35
c. [1] 35 34 33 32 31 30
5
8. Which one of the following is the correct output of the command
sqrt(abs(seq(-15,15, by = 6))) ?
9. Which one of the following is the correct output of the command seq(20,-20,
by = -4)?
10. Which one of the following is the correct output of the command
a. [1] -209 -208 -207 -206 -205 -204 -203 -202 -201 -200
b. [1] 191 192 193 194 195 196 197 198 199 200
c. [1] -191 -192 -193 -194 -195 -196 -197 -198 -199 -200
d. [1] 200 201 202 203 204 205 206 207 208 209
6
11. Which one of the following is the correct output of the command seq(to = -
100, length = 10) ?
a. [1] -109 -108 -107 -106 -105 -104 -103 -102 -101 -100
b. [1] 109 108 107 106 105 104 103 102 101 100
c. [1] 100 101 102 103 104 105 106 107 108 109
d. [1] -100 -101 -102 -103 -104 -105 -106 -107 -108 -109
12. Which one of the following is the correct output of the command
13. Which one of the following is the correct output of the command
7
14. Which one of the following is the correct output of Y for the following commands
a. [1] 1 2 3 4 5 6 7 8 9
b. [1] 7 6 3 8 1 9 4 5 2
c. [1] 2 5 4 9 1 8 3 6 7
d. [1] 9 8 7 6 5 4 3 2 1
15. Which one of the following is the correct output of Y[X[3]] and Y[X[7]]
for the command
X = c(5, 7, 1, 4, 6, 3, 2) ?
a. 51 and 87 respectively.
b. 1 and 2 respectively.
c. 17 and 90 respectively.
d. 90 and 17 respectively.
8
16. Which one of the following is the correct outcome of the command x[(x>50)]
where
x = c(20, 65, 27, 55, 38, 37, 18, 52, 160, 237, 170, 61, 88,
52, 49, 12, 4, 24, 18, 22) ?
b. [1] 9
c. [1] TRUE
d. [1] FALSE
17. Which one of the following is the correct outcome of the command
x[(x - 50 > 30)] where
x = c(20, 65, 27, 55, 38, 37, 18, 52, 160, 237, 170, 61, 88,
52, 49, 12, 4, 24, 18, 22) ?
c. [1] NULL
d. [1] 12
9
18. Which one of the following is the correct outcome of the command
x[(x^2 + 6*x < 500)] where
x = c(20, 65, 27, 55, 38, 37, 18, 52, 160, 237, 170, 61, 88,
52, 49, 12, 4, 24, 18, 22) ?
b. [1] 20, 65, 27, 55, 38, 37, 18, 52, 160, 237, 170, 61, 88,
52, 49, 12, 4, 24, 18, 22
c. [1] 18 12 4 18
d. [1] NULL
19. If y = 15:25 then which one of the following is the correct outcome of the
command y[ - (3:10)] ?
a. [1] 17 18 19 20 21 22 23 24
b. [1] 15 16 25
c. [1] 18 19 20 21 22 23 24 25
10
MOOC Course - Foundations of R Software
Answers of Assignment 6
1. c
2. b
3. c
4. a
5. d
6. b
7. a
8. b
9. d
10. b
11. a
12. c
13. b
14. a
15. d
16. a
17. b
18. c
19. b
11
MOOC Course - Foundations of R Software
July 2022
Assignment 7
1. Which one of the following is the correct command to generate a sequence of three
yearly dates 1-July-2020, 1- July-2021 and 1- July-2022?
b. seq(as.date("2020-03-01"), as.date("2021-03-01"),
as.date("2022-03-01"),by = "years")
2. Which one of the following is the correct command to generate the dates of 6
consecutive months starting from 15 March 2022?
1
3. Which one of the following is the correct outcome of the command letter[2:7]?
4. Which one of the following is the correct outcome of the command LETTERS[15:10] ?
5. Which one of the following is the correct outcome of the command rep(5:9,3)?
a. [1] 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9
b. [1] 5 6 6 7 7 7 8 8 8 8 9 9 9 9 9
c. [1] 5 6 7 8 9 5 6 7 8 9 5 6 7 8 9
d. [1] 9 8 7 6 5 9 8 7 6 5 9 8 7 6 5
2
6. Which one of the following is the correct outcome of the command
rep(50:46, times=4) ?
a. [1] 50 49 48 47 46 50 49 48 47 46 50 49 48 47 46 50 49 48 47 46
b. [1] 46 47 48 49 50 46 47 48 49 50 46 47 48 49 50 46 47 48 49 50
c. [1] 50 50 50 50 49 49 49 49 48 48 48 48 47 47 47 47 46 46 46 46
d. [1] 46 46 46 46 47 47 47 47 48 48 48 48 49 49 49 49 50 50 50 50
7. Which one of the following is the correct outcome of the command rep(35:40,
each=4) ?
a. [1] 35 36 37 38 39 40 35 36 37 38 39 40 35 36 37 38 39 40 35 36
37 38 39 40
b. [1] 35 35 35 35 36 36 36 36 37 37 37 37 38 38 38 38 39 39 39 39
40 40 40 40
c. [1] 40 40 40 40 39 39 39 39 38 38 38 38 37 37 37 37 36 36 36 36
35 35 35 35
d. [1] 40 39 38 37 36 35 40 39 38 37 36 35 40 39 38 37 36 35 40 39
38 37 36 35
3
8. Which one of the following is the correct outcome of the commands
rep(x, each=2) ?
a. [1] 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1
b. [1] 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9
c. [1] 9 8 7 6 5 4 3 2 1 9 8 7 6 5 4 3 2 1
d. [1] 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
9. Which one of the following is the correct outcome of the command rep(c("CLASS1",
" CLASS2", " CLASS3"), each=3) ?
a. [1] "CLASS1" "CLASS1" "CLASS1" " CLASS2" " CLASS2" " CLASS2"
" CLASS3" " CLASS3" " CLASS3"
b. [1] "CLASS1" "CLASS2" "CLASS3" " CLASS1" " CLASS2" " CLASS3"
" CLASS1" " CLASS2" " CLASS3"
4
10. Which one of the following is the correct outcome of the command
sort(c(15,55,18,32,97,71,82,42,66), decreasing = FALSE)?
a. [1] 1 5 2 3 9 7 8 4 6
b. [1] 6 4 8 7 9 3 2 5 1
c. [1] 15 18 32 42 55 66 71 82 97
d. [1] 97 82 71 66 55 42 32 18 15
11. Which one of the following is the correct outcome of the command
a. [1] 1 5 2 3 9 7 8 4 6
b. [1] 6 4 8 7 9 3 2 5 1
c. [1] 15 18 32 42 55 66 71 82 97
d. [1] 97 82 71 66 55 42 32 18 15
12. Which one of the following is the correct outcome of the command
order(c(15,55,18,32,97,71,82,42,66), decreasing = FALSE) ?
a. [1] 15 18 32 42 55 66 71 82 97
b. [1] 97 82 71 66 55 42 32 18 15
c. [1]1 3 4 8 2 9 6 7 5
d. [1] 5 7 6 9 2 8 4 3 1
5
13. Which one of the following is the correct outcome of the command
mode(c(10, 20, "30", 80+90, "70+90", 16.7, 10*5))?
a. character
b. numeric
c. list
d. data frame
14. Which one of the following is the correct outcome of the command x[[3]] where,
x =list (c("class1", "class2", "class3"), seq(from=50, to=57),
rep(28:30, each=3)) ?
a. [1] "class1" "class2" "class3"
b. [1] 50 51 52 53 54 55 56 57
c. [1] 28 28 28 29 2929 30 30 30
d. [1] "class3" 52 28
15. Which one of the following is the correct outcome of the command x[[2]][2]
where x =list (c("class1", "class2", "class3"), seq(from=50, to=57),
rep(28:30, each=3)) gives an output as
a. [1] "class2"
b. [1] 51
c. [1] 29
d. [1] 50 51 52 53 54 55 56 57
6
16. Which one of the following is the correct outcome of the command x[2][2] where
b. 51
c. 29
d. "NULL"
17. Which one of the following is the correct outcome of the command x[3] where
x =list (c("class1", "class2", "class3"), seq(from=50, to=57),
rep(28:30, each=3)) ?
a. [1] "class3"
b. [1] 28 28 28 29 29 29 30 30 30
c. [1] 52
d. [1] 50 51 52 53 54 55 56 57
18. Consider the list z = list(x1 = "class", x2 = 20:25). Which one of the
following is the correct outcome of the command z["x2"] ?
a. [1] "class"
b. [1] "20:25"
c. [1] 25 24 23 22 21 20
d. [1] 20 21 22 23 24 25
7
MOOC Course - Foundations of R Software
Answers of Assignment 7
1. a
2. c
3. d
4. b
5. c
6. a
7. b
8. b
9. a
10. c
11. d
12. c
13. a
14. c
15. b
16. d
17. b
18. d
8
MOOC Course - Foundations of R Software
July 2022
Assignment 8
1. Consider the list x=list("UP", "MP", "J&K", "Bihar", 20, 40, "60+40").
Which one of the following is the correct outcome of the command append(x, 200) ?
a.
[[1]]
[1] 200
[[2]]
[1] "UP"
[[3]]
[1] "MP"
[[4]]
[1] "J&K"
[[5]]
[1] "Bihar"
[[6]]
[1] 20
[[7]]
[1] 40
[[8]]
[1] "60+40"
1
b.
[[1]]
[1] "200"
[[2]]
[1] "UP"
[[3]]
[1] "MP"
[[4]]
[1] "J&K"
[[5]]
[1] "Bihar"
[[6]]
[1] 20
[[7]]
[1] 40
[[8]]
[1] 100
c.
[[1]]
[1] "UP"
[[2]]
[1] "MP"
[[3]]
[1] "J&K"
[[4]]
[1] "Bihar"
[[5]]
[1] 20
[[6]]
[1] 40
[[7]]
[1] "60+40"
[[8]]
[1] 200
2
d.
[[1]]
[1] "UP"
[[2]]
[1] "MP"
[[3]]
[1] "J&K"
[[4]]
[1] "Bihar"
[[5]]
[1] 40
[[6]]
[1] 20
[[7]]
[1] "60+40"
[[8]]
[1] "200"
3
2. Consider the list x=list("UP", "MP", "J&K", "Bihar", 20, 40, "60+40").
Which one of the following is the correct outcome of the command append(x, 200,
after =2) ?
a.
[[1]]
[1] "UP"
[[2]]
[1] "MP"
[[3]]
[1] 200
[[4]]
[1] "J&K"
[[5]]
[1] "Bihar"
[[6]]
[1] 20
[[7]]
[1] 40
[[8]]
[1] "60+40"
b.
[[1]]
[1] "UP"
[[2]]
[1] "MP"
[[3]]
[1] "200"
[[4]]
[1] "J&K"
[[5]]
[1] "Bihar"
[[6]]
4
[1] 20
[[7]]
[1] 20
[[8]]
[1] "60+40"
c.
[[1]]
[1] "UP"
[[2]]
[1] "MP"
[[3]]
[1] "J&K"
[[4]]
[1] "Bihar"
[[5]]
[1] 20
[[6]]
[1] 40
[[7]]
[1] "60+40"
[[8]]
[1] 200
d.
[[1]]
[1] "UP"
[[2]]
[1] "MP"
[[3]]
[1] "J&K"
[[4]]
[1] "Bihar"
5
[[5]]
[1] 20
[[6]]
[1] 40
[[7]]
[1] "60+40"
[[8]]
[1] "200"
3. Consider the list x=list("UP", "MP", "J&K", "Bihar", 20, 40, "60+40").
Which one of the following is the correct outcome of the command x[2:3] ?
a.
[[1]]
[[6]]
[1] 20
[[7]]
[1] 40
b.
[[1]]
[1] "MP"
[[2]]
[1] "J&K"
6
c.
[2] "MP" [3] "J&K"
d.
[[1]]
[1] "UP"
[[2]]
[1] "MP"
[[3]]
[1] "J&K"
[[4]]
[1] "Bihar"
[[5]]
[1] 20
[[6]]
[1] 40
[[7]]
[1] "60+40"
[[8]]
[1] "200"
a. names(z)[2]= y2
b. names(z)[2]= "y2"
c. names(y)[2]= "z2"
d. names(y)[2]= z2
7
5. Which one of the following is the correct outcome of the command
factor(c(10,10,20,20,30,30)) ?
a.
[1] 10 10 20 20 30 30
Levels: 10 20 30
b.
[1] 10 20 30
Levels: 10 20 30
c.
[1] 10 20 30
Levels: 10 10 20 20 30 30
d.
[1] 10 10 20 20 30 30
Levels: 10 10 20 20 30 30
6. Which one of the following is the correct outcome of the following commands?
data = c(4,4,2,2,6,6,9)
factor(data)
levels(data) = c('A','B','C','D')
data
a.
[1] 4 4 2 2 6 6 9
attr(,"levels")
[1] "A" "B" "C" "D"
b.
[1] 4 2 6 9
attr(,"levels")
8
[1] "A" "B" "C" "D"
c.
[1] A A B B C C D
Levels: 1 2 3
d.
[1] B A C D
attr(,"levels")
[1] "2" "4" "6" "9"
x = factor(c(10,20,20,50,10,20,10,50,60,60),
levels=c(10,20,50,60),ordered=TRUE) ?
a.
b.
[1] 10 20 50 60
Levels: 10 20 20 50 10 20 10 50 60 60
c.
[1] 10 20 20 50 10 20 10 50 60 60
Levels: 10 < 20 < 50 < 60
d.
[1] 10 20 20 50 10 20 10 50 60 60
Levels: 1 < 2 < 5 < 6
9
8. Which one is the correct outcome of the command
factor( c(rep("head",3), rep("tale", 4))) ?
a.
[1] head tale
Levels: head head head tale tale tale tale
b.
[1] head head head head tale tale tale
Levels: head tale
c.
[1] tale tale tale tale head head head
Levels: head tale
d.
[1] head head head tale tale tale tale
Levels: head tale
10
9. Which one of the following is the correct outcome of the command
unclass(factor( c("high school", "graduation", "post graduation", "
graduation", "high school", "post graduation", "high school", "post
graduation"), levels=c("high school", "graduation", "post graduati
on") )) ?
a.
[1] 1 2 3 2 1 3 1 3
attr(,"levels")
[1] "high school" "graduation" "post graduation"
b.
[1] 3 2 1 2 3 1 3 1
attr(,"levels")
[1] "post graduation" "graduation" "high school"
c.
[1] 1 2 3
attr(,"levels")
[1] "high school" "graduation" "post graduation"
d.
[1] 3 2 1
attr(,"levels")
[1] "post graduation" "graduation" "high school"
11
10. Which one of the following is the correct outcome of the command
as.factor(c(1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5) ) ?
a.
[1] 1 2 3 4 5
Levels: 1 2 3 4 5
b.
[1] 5 5 5 4 4 3 3 3 2 2 1
Levels: 5 4 3 2 1
c.
[1] 1 2 2 3 3 3 4 4 5 5 5
Levels: 1 2 3 4 5
d.
[1] 1 2 2 3 3 3 4 4 5 5 5
Levels: 5 4 3 2 1
11. Which one of the following is the correct outcome of the command
print(2/3,digits=6) ?
a. [1] 0.66667
b. [1] 0.6667
c. [1] 0.666667
d. [1] 0.667
12
12. Which one of the following is the correct outcome of the command
print("The average marks of the class is", (40+10)/3, "in first yea
r.", digits=5) ?
a. [1] "The average marks of the class is" 16.667 "in first year."
13. Which one of the following is the correct outcome of the command
print("My house has"); print(2+4); print("rooms.") ?
a. [1] "My house has" 6 "rooms."
b.
[1] "My house has"
[1] 6
[1] "rooms."
c. [1] "My house has" 2+4 "rooms."
d. [1] My house has 6 rooms.
14. Which one of the following is the correct outcome of the command
format(12345678910, big.mark = "*") ?
a. "1*2*3*4*5*6*7*8*9*1*0"
b. "123*45*678*910"
c. "12*34*56*78*91*0"
d. "12*345*678*910"
13
15. Which one of the following is the correct outcome of the command
print( format( 2.5, digits=6, nsmall=10 ) ) ?
a. "2.5"
b. "2.5000"
c. "2.5000000000"
d. "2.500000"
14
MOOC Course - Foundations of R Software
Answers of Assignment 8
1. c
2. a
3. b
4. b
5. a
6. a
7. c
8. d
9. a
10. c
11. c
12. c
13. b
14. d
15. c
15
MOOC Course - Foundations of R Software
July 2022
Assignment 9
a.
[1] Indian Institute of Technology Kanpur!\n
and
[1] Indian Institute of Technology Kanpur!\n
b.
[1] "Indian Institute of Technology Kanpur!"
and
Indian Institute of Technology Kanpur!\n
c.
[1] "Indian Institute of Technology Kanpur!"
and
Indian Institute of Technology Kanpur!\n
d.
[1] "Indian Institute of Technology Kanpur!\n"
and
Indian Institute of Technology Kanpur!
2. Which one of the following is the correct outcome of the command
print(paste("R course has", 10* 2:4, "students"))?
a. [1] "R course has" 10* 2 "students" "R course has" 10* 3 "
students" "R course has" 10* 4 "students"
b. [1] "R course has 20 students" "R course has 30 students" "
R course has 40 students"
c. "The square root of" "x" "is" 6 " and the cube root of y is"
3 !\n
b. [1] "The age of 3 students are 18 years, and The age of 3 stu
dents are 19 years, and The age of 3 students are 20 years"
a.
[1] "Students in class 1 are:50" "Students in class 2 are:51" "
b.
c.
d.
a.
[1] "Total number of pages in books are+200Total number of page
s in books are+201Total number of pages in books are+202"
b.
[1] "Total number of pages in books are+200+201+202"
c.
[1] "Total number of pages in books are 603"
d.
[1] "Total number of pages in books are 200" + "Total number o
f pages in books are 201" + "Total number of pages in books are
202"
8. Which one of the following is the correct outcome of y where
y=strsplit("Landlord of House Number 100::Landlord of House Num
ber 200::Landlord of House Number 300","::") ?
a.
[[1]]
[1] " Landlord of House Number 100:200::300"
b.
[[1]]
[1]
Landlord of House Number 100, Landlord of House Number 200, Lan
dlord of House Number 300,
c.
[[1]]
[1] "Landlord of House Number 100" "Landlord of House Number 20
0" "Landlord of House Number 300"
d.
[[1]]
[1] "Landlord of House Number 100"::"Landlord of House Number 2
00"::"Landlord of House Number 300"
9. Let
y=strsplit("Landlord of House Number 100::Landlord of House Num
ber 200::Landlord of House Number 300","::")
Which one of the following is the correct command to get the outcome of y as "Lan
dlord of House Number 300" ?
a. y[1][3]
b. y[3][1]
c. y[[1]][3]
d. [[3]][1]
10. Which one of the following is the correct outcome of the command
nchar("NPTEL - National Programme on Technology Enhanced Learni
ng- is a joint initiative of the IITs and IISc.") ?
a. [1] 99
b. [1] 100
c. [1] 101
d. [1] 103
11. Which one of the following is the correct outcome of the command
nzchar("NPTEL - National Programme on Technology Enhanced Learn
ing- is a joint initiative of the IITs and IISc.") ?
a. TRUE
b. FALSE
c. 103
d. 101
12. Which one of the following is the correct outcome of nzchar(x) where
x=c("NPTEL - National Programme on Technology Enhanced
Learning-", "is a joint initiative of the", "IITs and IISc.")?
a. TRUE
b. FALSE
c. FALSE FALSE FALSE
d. TRUE TRUE TRUE
13. Which one of the following is the correct outcome of the command tolower("
InDIan InStItUtE Of TEchNOloGY") ?
a. [1] "Indian Institute Of Technology")
14. Which one of the following is the correct outcome of the command toupper("
Institute Of National Importance in India") ?
a. [1] "institute of national importance in india"
1. d
2. b
3. d
4. c
5. b
6. d
7. a
8. c
9. c
10. d
11. a
12. d
13. b
14. c
MOOC Course - Foundations of R Software
July 2022
Assignment 10
b. [1] "cdef"
c. [1] 1 3 4 5
d. [1] 2
b. [1] m n o p q r
c. [1] 13–14–15–16-17-18
d. [1] 13 14 15 16 17 18
b. TRUE
c. FALSE
7. Which one of the following is the correct command to obtain the dimension, name,
and type of each variable in a data frame mtcars ?
a. string(mtcars)
b. strname(mtcars)
c. str(mtcars)
d. stringname(mtcars)
8. Which one of the following is the correct command to extract the variable gear fro
m a data frame mtcars ?
a. gear$mtcars
b. name(mtcars$gear)
c. name(gear$mtcars)
d. mtcars$gear
9. Which one of the following is the correct command to extract the first five data point
s contained in the variable mpg from a data frame mtcars?
a. mpg$mtcars[1:5]
b. mtcars$mpg[1:5]
c. mtcars$mpg[1,5]
d. [mtcars,suzuki](1,5)
Answer Questions 10-12 on the basis of the following information:
Consider the data frame painters in the library MASS. Use command library(M
ASS) to load the library MASS and use the command attach(painters) to attac
h the database painters.
10. Which one of the following is respectively the correct command to draw informatio
n on those painters who have used the "Colour" coded as 6 and are from "School" F fr
om the data frame painters and what is the corresponding outcome?
a.
subset(painters, Colour==6 & School==F)
and
Composition Drawing Colour Expression School
Pourbus 4 15 6 6 F
Van Leyden 8 6 6 4 F
b.
subset(painters, Colour=6 & School=F)
and
Composition Drawing Colour Expression School
Pourbus 4 15 6 6 F
Van Leyden 8 6 6 4 F
c.
subset(painters, Colour=='6' & School=='F')
and
Composition Drawing Colour Expression School
Pourbus 4 15 6 6 F
Van Leyden 8 6 6 4 F
d.
subset(painters, Colour=='6' and School=='F')
and
Composition Drawing Colour Expression
Pourbus 4 15 6 6
Van Leyden 8 6 6 4
11. Which one of the following is respectively the correct command to draw the inform
ation on those painters who have used the "Composition" as 15 and "Expression" is
more than 9 and what is the output from the data frame painters?
a.
subset(painters, Composition =='15' & Expression > 9)
and
Composition Drawing Colour Expression School
Perino del Vaga 15 16 7 6 A
Tintoretto 15 14 16 4 D
Veronese 15 10 16 3 D
Teniers 15 12 13 6 G
b.
subset(painters, Composition =='15' & Expression > 9)
and
Composition Drawing Colour Expression School
Da Vinci 15 16 4 14 A
Guilio Romano 15 16 4 14 A
Primaticcio 15 14 7 10 B
Vanius 15 15 12 13 C
Domenichino 15 17 9 17 E
The Carraci 15 17 13 13 E
Rembrandt 15 6 17 12 G
Van Dyck 15 10 17 13 G
Le Suer 15 15 4 15 H
Poussin 15 17 6 15 H
c.
subset(painters, Composition =='15' & Expression > '9')
and
Composition Drawing Colour Expression School
Da Vinci 15 16 4 14 A
Guilio Romano 15 16 4 14 A
Primaticcio 15 14 7 10 B
Vanius 15 15 12 13 C
Domenichino 15 17 9 17 E
The Carraci 15 17 13 13 E
Rembrandt 15 6 17 12 G
Van Dyck 15 10 17 13 G
Le Suer 15 15 4 15 H
Poussin 15 17 6 15 H
d.
subset(painters, Composition =15 & Expression > 9)
and
Composition Drawing Colour Expression School
Da Udine 10 8 16 3 A
Da Vinci 15 16 4 14 A
Del Piombo 8 13 16 7 A
Del Sarto 12 16 9 8 A
Fr. Penni 0 15 8 0 A
Guilio Romano 15 16 4 14 A
Michelangelo 8 17 4 8 A
Perino del Vaga 15 16 7 6 A
Perugino 4 12 10 4 A
Raphael 17 18 12 18 A
F. Zucarro 10 13 8 8 B
Fr. Salviata 13 15 8 8 B
Parmigiano 10 15 6 6 B
Primaticcio 15 14 7 10 B
T. Zucarro 13 14 10 9 B
Volterra 12 15 5 8 B
Barocci 14 15 6 10 C
Cortona 16 14 12 6 C
Josepin 10 10 6 2 C
L. Jordaens 13 12 9 6 C
Testa 11 15 0 6 C
Vanius 15 15 12 13 C
Bassano 6 8 17 0 D
Bellini 4 6 14 0 D
Giorgione 8 9 18 4 D
Murillo 6 8 15 4 D
Palma Giovane 12 9 14 6 D
Palma Vecchio 5 6 16 0 D
Pordenone 8 14 17 5 D
Tintoretto 15 14 16 4 D
Titian 12 15 18 6 D
Veronese 15 10 16 3 D
Albani 14 14 10 6 E
Caravaggio 6 6 16 0 E
Corregio 13 13 15 12 E
Domenichino 15 17 9 17 E
Guercino 18 10 10 4 E
Lanfranco 14 13 10 5 E
The Carraci 15 17 13 13 E
Durer 8 10 10 8 F
Holbein 9 10 16 13 F
Pourbus 4 15 6 6 F
Van Leyden 8 6 6 4 F
Diepenbeck 11 10 14 6 G
J. Jordaens 10 8 16 6 G
Otho Venius 13 14 10 10 G
Rembrandt 15 6 17 12 G
Rubens 18 13 17 17 G
Teniers 15 12 13 6 G
Van Dyck 15 10 17 13 G
Bourdon 10 8 8 4 H
Le Brun 16 16 8 16 H
Le Suer 15 15 4 15 H
Poussin 15 17 6 15 H
12. Which one of the following are respectively the correct commands to draw the info
rmation and output on those painters who have used the "Colour" coded as 4 , "Scho
ol" as A when information on the variables "Drawing" and "Expression" is removed fro
m the data frame painters and its corresponding outcome?
a.
subset(painters, School=A & Colour=, select=c(-2,-4))
and
Composition Colour School
Da Vinci 15 4 A
Guilio Romano 15 4 A
Michelangelo 8 4 A
b.
subset(painters, School=="A" & Colour=="4", select=c(-2,-4))
and
Composition Drawing Colour Expression School
Da Vinci 15 16 4 14 A
Guilio Romano 15 16 4 14 A
Michelangelo 8 17 4 8 A
c.
subset(painters, School=A & Colour=4, select=c(-2,-4))
and
Composition Drawing Colour Expression School
Da Vinci 15 16 4 14 A
Guilio Romano 15 16 4 14 A
Michelangelo 8 17 4 8 A
d.
subset(painters, School=="A" & Colour=="4", select=c(-2,-4))
and
Composition Colour School
Da Vinci 15 4 A
Guilio Romano 15 4 A
Michelangelo 8 4 A
13. Suppose x = c("Germany", "India", "USA") and y = c(10, 20, 30)
then which of the following is the correct outcome of the command rbind(x,y)when
executed in R console?
A.
B.
x y
[1,] "Germany" "10"
[2,] "India" "20"
[3,] "USA" "30"
C.
D.
y x
[1,] "10" "Germany"
[2,] "20" "India"
[3,] "30" "USA"
14. Suppose x = c("Germany", "India", "USA") and y = c(10, 20, 30)
then which of the following is the correct outcome of the command cbind(x,y)when
executed in R console?
A.
B.
C.
x y
[1,] "Germany" "10"
[2,] "India" "20"
[3,] "USA" "30"
D.
y x
[1,] "10" "Germany"
[2,] "20" "India"
[3,] "30" "USA"
MOOC Course - Foundations of R Software
Answers of Assignment 10
1. b
2. a
3. c
4. d
5. a
6. a
7. c
8. d
9. b
10. c
11. b
12. d
13. a
14. c
MOOC Course - Foundations of R Software
July 2022
Assignment 11
2. A tabular data file named as course1.txt where the values are separated b
y blank space and having header can be correctly read in R by which of the f
ollowing command?
a. read.table("course1.txt", header= TRUE, sep = " ")
b. read.txt("course1.txt", header=FALSE, sep = " ")
c. tabularread(course1.txt, header=FALSE, sep = " ")
d. read.table(course1.txt, header= TRUE, sep = )
5. Suppose two dice are rolled 10 times and following is the sum of the numbers on
the upper faces of the dice: 6,3,12,12,7,7,7,6,3,2. Which one of the following is the
correct command to obtain the absolute frequencies of this data in R?
a. table(c(6,3,12,12,7,7,7,6,3,2))
b. table(6,3,12,12,7,7,7,6,3,2)
c. table(c(6,3,12,12,7,7,7,6,3,2))/length(c(6,3,12,12,7,7,7,6,3
,2))
d. table(6,3,12,12,7,7,7,6,3,2)/length(6,3,12,12,7,7,7,6,3,2)
6. Suppose two dice are rolled 20 times and the following are the sum of numbers
on the upper face: 8, 8, 7, 12, 2, 3, 5, 3, 4, 6, 7, 6, 5, 6, 6, 7, 4, 3, 2, 9, 9. Which one
of the following is the correct outcome of the following command in R?
table(c(8,8,7,12,2,3,5,3,4,6,7,6,5,6,6,7,4, 3,2,9))
a.
2 3 4 5 6 7 8 9 12
0.10 0.15 0.10 0.10 0.20 0.15 0.10 0.10 0.05
b.
2 3 4 5 6 7 8 9 12
1 1 1 1 1 1 1 2 1
c.
2 3 4 5 6 7 8 9 12
2 3 2 2 4 3 2 1 1
d.
2 3 2 2 4 3 2 1 1
2 3 4 5 6 7 8 9 12
7. Which one of the following is the correct command to obtain the 2nd , 5th, 7th and
9th deciles of a data vector x in R?
a. decile(x, probs=c(20%,50%,70%,90%))
b. decile(x, probs=(0.20,0.50,0.70,0.90))
c. quantile(x, probs=(20%,50%,70%,90%))
d. quantile(x, probs=c(0.20,0.50,0.70,0.90))
8. Which one of the following correctly specify the quantiles of a data vector marks
obtained as an outcome of the command quantile(marks, probs = seq(0,
1, 0.15)) in R?
a. 15th
b. 0th,15th,30th,45th,60th,75th,90th
c. 15th,30th,45th,60th,75th,90th
d. 15th,45th,90th
9. Suppose two dice are rolled 10 times and the following sum of the numbers on
the upper faces of the dice: 6,3,12,12,7,7,7,6,3,2. Which of the following command
in R is used to obtain the bar plot of this data based on relative frequencies?
a. barplot(6,3,12,12,7,7,7,6,3,2)/length(6,3,12,12,7,7,7,6,3,2)
b. barplot(table(6,3,12,12,7,7,7,6,3,2)/length(6,3,12,12,7,7,7,6,
3,2))
c. barplot(c(6,3,12,12,7,7,7,6,3,2))/length(c(6,3,12,12,7,7,7,6,3
,2)))
d. barplot(table(c(6,3,12,12,7,7,7,6,3,2))/length(c(6,3,12,12,7,7,
7,6,3,2)))
10. Suppose two dice are rolled 10 times and the following sum of the numbers on
the upper faces of the dice: 6,3,12,12,7,7,7,6,3,2. Which of the following command i
n R is used to obtain the bar plot of this data based on absolute frequencies having
the main title as “Sum of Numbers on Dice” and all the bars are filled in red colour?
1. d
2. a
3. a
4. c
5. a
6. c
7. d
8. b
9. d
10. a