R Language quiz questions

R Language interview questions

  • 1.

    Which of the followin code represents internal representation of a Date object ?

    1. class(as.Date(“1970-01-02”))

    2. unclass(as.Date(“1970-01-02”))

    3. unclassint(as.Date(“1970-01-02”))

    4. All of the mentioned

    Answer
  • 2.

    What would be the output of the following code ?

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

     

    1. [,1] [,2]
      [1,] 10 30
      [2,] 20 40
    2. [,1] [,2]
      [1,] 10 30
      [2,] 30 40
    3. [,1] [,2]
      [1,] 20 30
      [2,] 20 40
    4. All of the mentioned

    Answer
  • 3.

    What would be the output of the following code ?

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

     

    1. 0.1666667 0.2857143 0.4444444

    2. 0.1666667 0.2857143 0.3750000 0.4444444

    3. 0.2857143 0.3750000 0.4444444

    4. All of the mentioned

    Answer
  • 4.

    Point out the wrong statement :

    1. Dates are represented by the Date class

    2. Times are represented by the POSIXct or the POSIXlt class

    3. Dates are represented by the DateTime class

    4. All of the mentioned

    Answer
  • 5.

    What would be the output of the following code ?

    > x <- 1:4
    > x > 2

     

    1. 1 2 3 4

    2. FALSE FALSE TRUE TRUE

    3. 1 2 3 4 5

    4. All of the mentioned

    Answer
  • 6.

    What would be the output of the following code ?

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

     

    1. 7 9 11 13

    2. 7 9 11 13 14

    3. 9 7 11 13

    4. NULL

    Answer
  • 7.

    Point out the wrong statement :

    1. Very less operations in R are vectorized

    2. Vectorization allows you to write code that is efficient, concise, and easier to read than in non-vectorized languages

    3. vectorized means that operations occur in parallel in certain R objects

    4. All of the mentioned

    Answer
  • 8.

    Which of the following is example of vectorized operation as far as subtraction is concerned ?

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

     

    1. x+y

    2. x-y

    3. x/y

    4. x–y

    Answer
  • 9.

    What would be the output of the following code ?

    > x <- c(1, 2, NA, 4, NA, 5)
    > bad <- is.na(x)
    > print(bad)

     

    1. FALSE FALSE FALSE FALSE TRUE FALSE

    2. FALSE TRUE TRUE FALSE TRUE FALSE

    3. FALSE FALSE TRUE FALSE TRUE FALSE

    4. None of the mentioned

    Answer
  • 10.

    What would be the output of the following code ?

    > x <- list(aardvark = 1:5)
    > x[["a", exact = FALSE]]

     

    1. 1 2 3 4 5

    2. 2 3 5

    3. 1 3 3 5

    4. 1 2 3

    Answer
  • 11.

    Which of the followin code extracts 1st element of the 2nd element ?

     > x <- list(a = list(10, 12, 14), b = c(3.14, 2.81))

     

    1. x[[c(2, 1)]]

    2. x[[c(1, 2)]]

    3. x[[c(2, 1,1)]]

    4. All of the mentioned

    Answer
  • 12.

    What would be the output of the following code ?

    > x <- list(aardvark = 1:5)
    > x$a

     

    1. 1 2 3 4 5

    2. 2 3 5

    3. 1 3 3 5

    4. 1 2 3

    Answer
  • 13.

    What would be the output of the following code ?

    > x <- list(a = list(10, 12, 14), b = c(3.14, 2.81))
    > x[[c(1, 3)]]

     

    1. 13

    2. 14

    3. 15

    4. All of the mentioned

    Answer
  • 14.

    Point out the wrong statement :

    1. $ operator semantics are similar to that of [[

    2. The [[ operator can take an integer sequence if you want to extract a nested element of a list

    3. The $ operator can be used to extract multiple elements from a list

    4. All of the mentioned

    Answer
  • 15.

    What would be the output of the following code ?

    > x <- list(foo = 1:4, bar = 0.6, baz = "hello")
    > name <- "foo"
    > x[[name]]

     

    1. 1 2 3 4

    2. 0 1 2 3

    3. 1 2 3 4 5

    4. All of the mentioned

    Answer
  • 16.

    What would be the output of the following code ?

    > x <- list(foo = 1:4, bar = 0.6, baz = "hello")
    > name <- "foo"
    > x$name

     

    1. 1

    2. 2

    3. 3

    4. NULL

    Answer
  • 17.

    Point out the correct statement :

    1. You can also use the $ operator to extract elements by name

    2. $ operator can be used with computed indices

    3. The [[ operator can only be used with literal names

    4. All of the mentioned

    Answer
  • 18.

    Which of the following extracts first element from the following list ?

     > x <- list(foo = 1:4, bar = 0.6)

     

    1. x[[1]]

    2. x[1]

    3. x[[0]]

    4. None of the mentioned

    Answer
  • 19.

    What would be the output of the following code ?

    > x <- list(foo = 1:4, bar = 0.6)
    > x

     

    1. $foo
      [1] 1 2 3 4
      $bar
      [1] 0.6
    2. $foo
      [1] 0 1 2 3 4
      $bar
      [1] 0 0.6
    3. $foo
      [1] 0 1 2 3 4
      $bar
      [1] 0.6
    4. None of the mentioned

    Answer
  • 20.

    What would be the output of the following code ?

    > x <- matrix(1:6, 2, 3)
    > x[1, , drop = FALSE]

     

    1. [,1] [,2] [,3]
      [1,] 1 3 5
    2. [,1] [,2] [,3]
      [1,] 2 3 5
    3. [,1] [,2] [,3]
      [1,] 1 2 5
    4. None of the mentioned

    Answer

© 2017 QuizBucket.org