Assignment 2: Accepted Answers
Assignment 2: Accepted Answers
Assignment 2
.
1) 1 point
Which one of the following is the correct specification to compute and
what is its value for x = 7590?
Accepted Answers:
y<- function(x){sqrt(log(x)+x^(1/3))}, y = 5.346673
2) Which one of the following is the correct outcome of z(12,14) of the function specified as 1 point
z=function(x,y){sqrt(x^2+y^2)+exp(-(x^-2+y^-2))-(x^2+y^2)^(2/4)}?
-29.28675
0.9880258
37.8662
None of these
Accepted Answers:
0.9880258
3) Which one of the following is the correct command to obtain the following matrix? 1 point
x=matrix(1:9,3,3,byrow=T)
x=mat(1:9,3,3, byrow=T)
x=matrix(1:9,3,3,byrow=F)
x=mat(1:9,3,3,byrow=F)
https://onlinecourses.nptel.ac.in/noc17_ma17/unit?unit=11&assessment=79 1/10
29/12/2017 Introduction to R Software - - Unit 3 - Week 2 - Use of R as a calculator, functions and matrix operations, missing data a…
Accepted Answers:
x=matrix(1:9,3,3,byrow=F)
4) Which one of the following is the correct command to obtain the following matrix? 1 point
Accepted Answers:
z <- matrix(nrow=2, ncol=3, data=c(5,6,7,8,9,10), byrow=T)
5) Which one of the following is the correct outcome of the command X[3,2] for the matrix 1 point
constituted by the command
X<-matrix(1:9,3,3,byrow=F)?
3
6
7
8
Accepted Answers:
6
6) Which one of the following is the correct outcome of the commands dim(x) and dim(y) for 1 point
the matrices obtained by
x<-matrix(1:100,50,2,byrow=T) and y<-matrix(1:100,50,2,byrow=F)?
50 2 and 2 50 respectively.
2 50 and 50 2 respectively.
2 50 and 2 50 respectively.
50 2 and 50 2 respectively.
Accepted Answers:
50 2 and 50 2 respectively.
7) Which one of the following is the correct outcome of the command x <- diag(3, 1 point
nrow=2, ncol=2)?
https://onlinecourses.nptel.ac.in/noc17_ma17/unit?unit=11&assessment=79 2/10
29/12/2017 Introduction to R Software - - Unit 3 - Week 2 - Use of R as a calculator, functions and matrix operations, missing data a…
Accepted Answers:
8) Which one of the following is the correct outcome of the command t(x) for 1 point
x<-matrix(nrow=3,ncol=2,data=6:11,byrow=T)?
[1,] 6 8 10
[2,] 7 9 11
[,1] [,2]
[1,] 6 9
[2,] 7 10
[3,] 8 11
[,1] [,2] [,3]
[1,] 6 7 8
[2,] 9 10 11
None of these
Accepted Answers:
[,1] [,2] [,3]
[1,] 6 8 10
[2,] 7 9 11
9) Which one of the following is the correct command to obtain the multiplication of two matrices1 point
x and y of the same order?
x*y
%*y
x%*%y
x%%*%%y
Accepted Answers:
x%*%y
10)Which one of the following is the correct command to obtain the multiplication of two matrices1 point
https://onlinecourses.nptel.ac.in/noc17_ma17/unit?unit=11&assessment=79 3/10
29/12/2017 Introduction to R Software - - Unit 3 - Week 2 - Use of R as a calculator, functions and matrix operations, missing data a…
x*y
[,1] [,2]
[1,] 19 22
[2,] 43 50
x*%*y
[,1] [,2]
[1,] 19 43
[2,] 22 50
x%*%y
[,1] [,2]
[1,] 19 22
[2,] 43 50
x%%*%%y
[,1] [,2]
[1,] 50 43
[2,] 22 19
Accepted Answers:
x%*%y
[,1] [,2]
[1,] 19 22
[2,] 43 50
11)Let x<- matrix(nrow=2, ncol=2, data=1:4, byrow=T) then which one of the 1 point
following is the correct outcome of 2*x ?
[,1] [,2]
[1,] 2 4
[2,] 6 8
[,1] [,2]
[1,] 2 6
https://onlinecourses.nptel.ac.in/noc17_ma17/unit?unit=11&assessment=79 4/10
29/12/2017 Introduction to R Software - - Unit 3 - Week 2 - Use of R as a calculator, functions and matrix operations, missing data a…
[2,] 4 8
[,1] [,2]
[1,] 2 4
[2,] 8 6
None of these
Accepted Answers:
[,1] [,2]
[1,] 2 4
[2,] 6 8
12)Which one of the following is the correct outcome of the addition of two matrices 1 point
x + y
[,1] [,2]
[1,] 6 8
[2,] 10 12
x %+% y
[,1] [,2]
[1,] 6 8
[2,] 12 10
x %%+%% y
[,1] [,2]
[1,] 10 12
[2,] 6 8
x %+%+ y
[,1] [,2]
[1,] 6 8
[2,] 10 12
https://onlinecourses.nptel.ac.in/noc17_ma17/unit?unit=11&assessment=79 5/10
29/12/2017 Introduction to R Software - - Unit 3 - Week 2 - Use of R as a calculator, functions and matrix operations, missing data a…
Accepted Answers:
x + y
[,1] [,2]
[1,] 6 8
[2,] 10 12
13)Let x<- matrix(nrow=2, ncol=2, data=1:4, byrow=T) then which one of the 1 point
following is the correct outcome of 2%*%x ?
[,1] [,2]
[1,] 2 4
[2,] 6 8
[,1] [,2]
[1,] 2 6
[2,] 4 8
Error....
None of these
Accepted Answers:
Error....
14)Which one of the following is the correct outcome of X[ ,2] for the matrix specified by 1 point
X<-matrix(nrow=3,ncol=3,data=c(10,20,30,40,50,60,70,80,90),byrow=F)?
[1] 40 50 60
[1] 20 50 80
[1] 10 50 90
None of these
Accepted Answers:
[1] 40 50 60
15)Which one of the following is the correct outcome of X[2:3,2:3] for the matrix specified by 1 point
X<-matrix(nrow=3, ncol=3, data=c(10,20,30,40,50,60,70,80,90),
byrow=F)?
[,1] [,2]
[1,] 50 60
[2,] 80 90
[,1] [,2]
[1,] 50 80
[2,] 60 90
https://onlinecourses.nptel.ac.in/noc17_ma17/unit?unit=11&assessment=79 6/10
29/12/2017 Introduction to R Software - - Unit 3 - Week 2 - Use of R as a calculator, functions and matrix operations, missing data a…
[,1] [,2]
[1,] 20 80
[2,] 30 90
None of these
Accepted Answers:
[,1] [,2]
[1,] 50 80
[2,] 60 90
16) 1 point
Which one of the following is the correct command to get the matrix from the
matrix specified by
X<-matrix(nrow=3,ncol=3,data=c(10,20,30,40,50,60,70,80,90),byrow=F)?
X[1:2, 1:2]
X[1:2, 2:3]
X[1:1, 2:2, 3:3, 4:4]
None of these
Accepted Answers:
X[1:2, 2:3]
17) 1 point
If then which one of the following is the correct command and its
outcome for obtaining the inverse of the matrix x?
solve(x) =
https://onlinecourses.nptel.ac.in/noc17_ma17/unit?unit=11&assessment=79 7/10
29/12/2017 Introduction to R Software - - Unit 3 - Week 2 - Use of R as a calculator, functions and matrix operations, missing data a…
Accepted Answers:
solve(x) =
18)Suppose x is any vector as x=c(100,200, 300, 1:100, NA) then which one of the 1 point
following is the correct outcome of the command mean(x)?
54.85437
140.2
Error.....
NA
Accepted Answers:
NA
19)Which one of the following is the correct outcome of the command (x<5)&&(x>2)& 1 point
(x<5)||(x>2)||(x==7) when x=3 and when x=-3 ?
Accepted Answers:
TRUE and FALSE respectively.
20)Suppose x = 3:7 then which one of the following is the correct outcome of the command 1 point
(x > 3)&(x < 5)?
https://onlinecourses.nptel.ac.in/noc17_ma17/unit?unit=11&assessment=79 8/10
29/12/2017 Introduction to R Software - - Unit 3 - Week 2 - Use of R as a calculator, functions and matrix operations, missing data a…
Accepted Answers:
FALSE TRUE FALSE FALSE FALSE
21)Suppose x = 33:53 then which one of the following correctly specifies the outcomes of the 1 point
following statements:
x[(x > 28) & (x < 59)] and x[(x > 28) || (x < 59)]?
Accepted Answers:
are the same for both as
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
22)Suppose x = 30:70 then which one of the following is the correct command to know that 1 point
which of the values in x are more than 20 and less than 50?
Accepted Answers:
x[(x > 20) & (x < 50)]
23)Suppose x = 53:97 then which one of the following is the correct outcome of 1 point
(x > 92) && (x < 85) and (x > 92) || (x < 85)?
Accepted Answers:
FALSE and TRUE respectively.
24)Suppose x = 3:7 then which one of the following is the correct outcome of x[(x > 2) || 1 point
(x < 5)]?
TRUE
FALSE
3 4 5 6 7
None of these
Accepted Answers:
https://onlinecourses.nptel.ac.in/noc17_ma17/unit?unit=11&assessment=79 9/10