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 is example of vectorized operation as far as subtraction is concerned ?

> x <- 1:4
> y <- 6:9

a) x+y
b) x-y
c) x/y
d) x–y

View Answer

Answer: b [Reason:] Subtraction, multiplication and division are also vectorized.

2. Point out the wrong statement :
a) Very less operations in R are vectorized
b) Vectorization allows you to write code that is efficient, concise, and easier to read than in non-vectorized languages
c) vectorized means that operations occur in parallel in certain R objects
d) All of the mentioned

View Answer

Answer: a [Reason:] Many operations in R are vectorized.

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

> x <- 1:4
> y <- 6:9
> z <- x + y
> z

a) 7 9 11 13
b) 7 9 11 13 14
c) 9 7 11 13
d) NULL

View Answer

Answer: a [Reason:] This is simplest example of adding two vectors together.

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

> x <- 1:4
> x > 2

a) 1 2 3 4
b) FALSE FALSE TRUE TRUE
c) 1 2 3 4 5
d) All of the mentioned

View Answer

Answer: b [Reason:] Another operation you can do in a vectorized manner is logical comparisons.

5. Point out the wrong statement :
a) Dates are represented by the Date class
b) Times are represented by the POSIXct or the POSIXlt class
c) Dates are represented by the DateTime class
d) All of the mentioned

View Answer

Answer: C [Reason:] Dates are stored internally as the number of days since 1970-01-01 while times are stored internally as the number of seconds since 1970-01-01.

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

> x <- 1:4
> y <- 6:9
> x/y

a) 0.1666667 0.2857143 0.4444444
b) 0.1666667 0.2857143 0.3750000 0.4444444
c) 0.2857143 0.3750000 0.4444444
d) All of the mentioned

View Answer

Answer: b [Reason:] Logical operations return a logical vector of TRUE and FALSE.

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

> x <- matrix(1:4, 2, 2)
> y <- matrix(rep(10, 4), 2, 2)
> x * y

a)

[,1] [,2]
[1,] 10 30
[2,] 20 40

b)

[,1] [,2]
[1,] 10 30
[2,] 30 40

c)

[,1] [,2]
[1,] 20 30
[2,] 20 40

d) All of the mentioned

View Answer

Answer: a [Reason:] Matrix operations are also vectorized, making for nicely compact notation.

8. Which of the followin code represents internal representation of a Date object ?
a) class(as.Date(“1970-01-02”))
b) unclass(as.Date(“1970-01-02”))
c) unclassint(as.Date(“1970-01-02”))
d) all of the mentioned

View Answer

Answer: b [Reason:] You can see the internal representation of a Date object by using the unclass() function.

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

> x <- as.Date("1970-01-01")
> x

a) “1970-01-01”
b) “1970-01-02”
c) “1970-02-01”
d) None of the mentioned

View Answer

Answer: a [Reason:] Dates are represented by the Date class and can be coerced from a character string using the as.Date() function.

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

> x <- Sys.time()
> class(x)

a) “POSIXct” “POSIXt”
b) “POSIXXt” “POSIXt”
c) “POSIXct” “POSIct”
d) None of the mentioned

View Answer

Answer: a [Reason:] Times can be coerced from a character string using the as.POSIXlt or as.POSIXct function.

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

.woocommerce-message { background-color: #98C391 !important; }