Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. Which of the following statement would print “0” “1” “2” “3” “4” “5” “6” for the following code ?

 > x <- 0:6

a) as.character(x)
b) as.logical(x)
c) as.numeric(x)
d) none of the mentioned

View Answer

Answer: a [Reason:] as.character would print number from 0 to 6.

2. Point out the correct statement :
a) rep() is be used for replicating an object in various complicated ways
b) seq() function has four arguments
c) sequence() is a more general facility for generating sequences
d) all of the mentioned

View Answer

Answer: a [Reason:] The simplest form is of rep representation is : > s5 >- rep(x, times=5).

3. What would be the result of following code ?

x <- c("a", "b", "c")
> as.numeric(x)

a) Warning
b) Error
c) Abnormal termination
d) All of the mentioned

View Answer

Answer: a [Reason:] NAs is introduced by coercion.

4. What would the following code print ?

> x <- c("a", "b", "c")
> as.logical(x)

a) a b c
b) NA NA NA
c) 0 1 2
d) All of the mentioned

View Answer

Answer: b [Reason:] When nonsensical coercion takes place, you will usually get a warning from R.

5. Point out the correct statement :
a) The elements of a logical vector cannot have the values TRUE, FALSE, and NA
b) Matrices are vectors with a dimension attribute
c) Numerical vectors are generated by conditions
d) All of the mentioned

View Answer

Answer: b [Reason:] The dimension attribute is itself an integer vector of length 2 (number of rows, number of columns).

6. Which of the following is invalid assignment ?
a)

 > m <- matrix(nrow = 2, ncol = 3)

b)

 > m <- matrix(nrow = 2, ncol = 3.5)

c)

 > m <- mat(nrow = 2, ncol = 3)

d) None of the mentioned

View Answer

Answer: a [Reason:] Matrix Entries can be thought of starting in the “upper left” corner and running down the columns.

7. What would be the output of the following code ?

 > m <- matrix(nrow = 2, ncol = 3)
 > dim(m)

a) 3 2
b) 2 3
c) 2 2
d) None of the mentioned

View Answer

Answer: b [Reason:] Matrices are constructed column-wise.

8. What would be the output of the following code ?

> m <- matrix(1:6, nrow = 2, ncol = 3)
> m

a)

[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6

b)

[,0] [,1] [,2]
[1,] 1 3 5
[2,] 2 4 6

c)

[,1] [,2] [,3]
[1,] 1 3 6
[2,] 2 4 5

d) All of the mentioned

View Answer

Answer: a [Reason:] Matrices can also be created directly from vectors by adding a dimension attribute.

9. What would the following code print ?

> m <- 1:10
> m

a) 1 2 3 4 5 6 7 8 9 10
b) 1 2 3 4 5 6 7 8 9 10 11
c) 0 1 2 3 4 5 6 7 8 9 10
d) None of the mentioned

View Answer

Answer: a [Reason:] Matrices can be created by column-binding.

10.What would the following code print ?

> x <- 1:3
> y <- 10:12
> cbind(x, y)

a)

x y
[1,] 6 10
[2,] 7 11
[3,] 8 12

b)

x y
[1,] 1 10
[2,] 2 11
[3,] 3 12

c)

x y
[1,] 1 4
[2,] 2 5
[3,] 3 6

d) None of the mentioned

View Answer

Answer: b [Reason:] Roughly cbind() forms matrices by binding together matrices horizontally, or column-wise, and rbind() vertically, or row-wise.

Synopsis and Project Report

You can buy synopsis and project from distpub.com. Just visit https://distpub.com/product-category/projects/ and buy your university/institute project from distpub.com