R Language quiz questions

R Language interview questions

  • 1.

    Point out the wrong statement :

    1. matrices or more generally arrays are multi-dimensional generalizations of vectors

    2. factors provide compact ways to handle categorical data

    3. vectors provide a convenient way to return the results of a statistical computation

    4. All of the mentioned

    Answer
  • 2.

    What would the following code print ?

    > x <- list(1, "a", TRUE, 1 + 4i)
    > x

    A)

    [[1]]
    [1] 1
     
    [[2]]
    [1] "a"
     
    [[3]]
    [1] TRUE
     
    [[4]]
    [1] 1+4i

    B)

    [[1]]
    [1] 2
     
    [[2]]
    [1] "b"
     
    [[3]]
    [1] TRUE
     
    [[4]]
    [1] 1+4i

    C)

    [[1]]
    [1] 3
     
    [[2]]
    [1] "a"
     
    [[3]]
    [1] TRUE
     
    [[4]]
    [1] 1+4i

    D) All of the mentioned

    1. A

    2. B

    3. C

    4. D

    Answer
  • 3.

    What would be the result of following code ?

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

     

    1. [,1] [,2] [,3]
      x 1 2 3
      y 10 11 12
    2. [,1] [,2] [,3]
      x 1 2 3
      y 10 11
    3. [,1] [,2] [,3]
      x 1 2 3
      y 4 5 6
    4. All of the mentioned

    Answer
  • 4.

    Point out the correct statement :

    1. Character strings are entered using either matching double (“) or single (‘) quotes

    2. Character vectors may be concatenated into a vector by the c() function

    3. Subsets of the elements of a vector may be selected by appending to the name of the vector an index vector in square brackets

    4. All of the mentioned

    Answer
  • 5.

    The ________ function takes an arbitrary number of arguments and concatenates them one by one into character strings.

    1. copy()

    2. paste()

    3. bind()

    4. None of the mentioned

    Answer
  • 6.

    What would the following code print ?

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

     

    1. x y
      [1,] 6 10
      [2,] 7 11
      [3,] 8 12
    2. x y
      [1,] 1 10
      [2,] 2 11
      [3,] 3 12
    3. x y
      [1,] 1 4
      [2,] 2 5
      [3,] 3 6
    4. None of the mentioned

    Answer
  • 7.

    What would the following code print ?

    > m <- 1:10
    > m

     

    1. 1 2 3 4 5 6 7 8 9 10

    2. 1 2 3 4 5 6 7 8 9 10 11

    3. 0 1 2 3 4 5 6 7 8 9 10

    4. None of the mentioned

    Answer
  • 8.

    What would be the output of the following code ?

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

     

    1. [,1] [,2] [,3]
      [1,] 1 3 5
      [2,] 2 4 6
    2. [,0] [,1] [,2]
      [1,] 1 3 5
      [2,] 2 4 6
    3. [,1] [,2] [,3]
      [1,] 1 3 6
      [2,] 2 4 5
    4. All of the mentioned

    Answer
  • 9.

    What would be the output of the following code ?

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

     

    1. 3 2

    2. 2 3

    3. 2 2

    4. None of the mentioned

    Answer
  • 10.

    Which of the following is invalid assignment ?

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

       

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

       

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

       

    4. None of the mentioned

    Answer
  • 11.

    Point out the correct statement :

    1. The elements of a logical vector cannot have the values TRUE, FALSE, and NA

    2. Matrices are vectors with a dimension attribute

    3. Numerical vectors are generated by conditions

    4. All of the mentioned

    Answer
  • 12.

    What would the following code print ?

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

     

    1. a b c

    2. NA NA NA

    3. 0 1 2

    4. All of the mentioned

    Answer
  • 13.

    Point out the correct statement :

    1. rep() is be used for replicating an object in various complicated ways

    2. seq() function has four arguments

    3. sequence() is a more general facility for generating sequences

    4. All of the mentioned

    Answer
  • 14.

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

     > x <- 0:6

     

    1. as.character(x)

    2. as.logical(x)

    3. as.numeric(x)

    4. None of the mentioned

    Answer
  • 15.

    Which of the following is used for generating sequences ?

    1. seq()

    2. sequence()

    3. order()

    4. None of the mentioned

    Answer
  • 16.

    _______ function returns a vector of the same size as x with the elements arranged in increasing order

    1. sort()

    2. orderasc()

    3. orderby()

    4. None of the mentioned

    Answer
  • 17.

    Which of the following code constructs vector of length 11 ?

    1. > v <- 3*x + y + 1

       

    2. > v <- 3*x + y + 2

       

    3. > v <- 2*x + y + 1

       

    4. All of the mentioned

    Answer
  • 18.

    What would be the output of the following code ?

    > sqrt(-17)

     

    1. -4.02

    2. 4.02

    3. NaN

    4. None of the mentioned

    Answer
  • 19.

    Which of the following is invalid assignment ?

    1.  > c(10.4, 5.6, 3.1, 6.4, 21.7) -> x

       

    2. > assign("x", c(10.4, 5.6, 3.1, 6.4, 21.7))

       

    3. > x <- c(10.4, 5.6, 3.1, 6.4, 21.7)

       

    4. None of the mentioned

    Answer
  • 20.

    Point out the correct statement :

    1. The usual operator, <-, can be thought of as a syntactic short-cut to expression operation

    2. Assignment can also be made using the function assignment()

    3. Vectors can be used in arithmetic expressions, in which case the operations are performed element by element

    4. None of the mentioned

    Answer

© 2017 QuizBucket.org