R Language quiz questions

R Language interview questions

  • 1.

    Point out the correct statement :

    1. unserialize is used for converting an R object into a binary format for outputting to a connection

    2. save is used for saving an arbitrary number of R objects in binary format to a file

    3. The read.data() function is one of the most commonly used functions for reading data

    4. All of the mentioned

    Answer
  • 2.

    Which of the following argument denotes if the file has a header line ?

    1. header

    2. sep

    3. file

    4. All of the mentioned

    Answer
  • 3.

    ________ is used for outputting a textual representation of an R object

    1. dput

    2. dump

    3. dget

    4. All of the mentioned

    Answer
  • 4.

    Point out the wrong statement :

    1. write.table is used for for writing tabular data to text files (i.e. CSV) or connections

    2. writeLines is used for for writing character data line-by-line to a file or connection

    3. dump is used for for dumping a textual representation of multiple R objects

    4. All of the mentioned

    Answer
  • 5.

    Which of the following is used for reading in saved workspaces ?

    1. unserialize

    2. load

    3. get

    4. None of the mentioned

    Answer
  • 6.

    Which of the following is used for reading tabular data ?

    1. read.csv

    2. dget

    3. readLines

    4. None of the mentioned

    Answer
  • 7.

    Which of the following statement changes column name to h and f ?

    1. colnames(m) <- c("h", "f")

    2. columnnames(m) <- c("h", "f")

    3. rownames(m) <- c("h", "f")

    4. None of the mentioned

    Answer
  • 8.

    What would be the output of the following code ?

    > m <- matrix(1:4, nrow = 2, ncol = 2)
    > dimnames(m) <- list(c("a", "b"), c("c", "d"))
    > m

     

    1. c d
      a 1 3
      b 2 4
    2. c d
      a 1 2
      b 2 3
    3. c d
      a 1 3
      b 4 2
    4. All of the mentioned

    Answer
  • 9.

    What would be the output of the following code ?

    > x <- 1:3
    > names(x)

     

    1. NULL

    2. 1

    3. 2

    4. None of the mentioned

    Answer
  • 10.

    Which of the following is invalid assignment ?

    1. > x <- list("Los Angeles" = 1, Boston = 2, London = 3)

       

    2. > names(x) <- c("New York", "Seattle", "Los Angeles")

       

    3. > name(x) <- c("New York", "Seattle", "Los Angeles")

       

    4. None of the mentioned

    Answer
  • 11.

    Point out the correct statement :

    1. Using factors with labels is better than using integers because factors are self-describing

    2. Factors are used to represent categorical data and can be unordered or ordered

    3. Factors are important in statistical modeling and are treated specially by modelling functions like lm() and glm()

    4. All of the mentioned

    Answer
  • 12.

    What would the following code print ?

    > x <- data.frame(foo = 1:4, bar = c(T, T, F, F))
    > ncol(x)

     

    1. 2

    2. 4

    3. 7

    4. All of the mentioned

    Answer
  • 13.

    Data frames can be converted to a matrix by calling data._______

    1. matr()

    2. mat()

    3. matrix()

    4. All of the mentioned

    Answer
  • 14.

    Point out the wrong statement :

    1. is.nan() is used to test objects if they are NA

    2. is.nan() is used to test for NaN

    3. NA values have a class also, so there are integer NA, character NA, etc

    4. All of the mentioned

    Answer
  • 15.

    Which of the following would print the following output ?

    foo bar
    1 1 TRUE
    2 2 TRUE
    3 3 FALSE
    4 4 FALSE

     

    1. > x <- data.frame(foo = 1:4, bar = c(F, T, F, F))
      > x

       

    2. > x <- data.frame(foo = 1:6, bar = c(F, T, F, F))
      > x

       

    3. > x <- data.frame(foo = 1:4, bar = c(T, T, F, F))
      > x

       

    4. None of the mentioned

    Answer
  • 16.

    What would the following code print ?

    > x <- c(1, 2, NaN, NA, 4)
    > is.na(x)

     

    1. FALSE FALSE TRUE TRUE FALSE

    2. FALSE TRUE TRUE TRUE FALSE

    3. TRUE FALSE TRUE TRUE FALSE

    4. None of the mentioned

    Answer
  • 17.

    Which of the following code snippet will create a vector with NAs in it ?

    1. x <- c(1, 2, NA, 10, 3)

    2. x <- cNA(1, 2, NA, 10, 3) 

    3. x <- NA(1, 2, NA, 10, 3)

    4. None of the mentioned 

    Answer
  • 18.

    What would be the output of the following code ?

    > x <- factor(c("yes", "yes", "no", "yes", "no"))
    > table(x)

     

    1. no yes
      2 3
    2. yes no
      2 3
    3. no yes
      2 2
    4. All of the mentioned

    Answer
  • 19.

    What would be the output of the following code ?

    > x <- vector("list", length = 5)
    > x

     

    1. NULL

    2. 1

    3. 0

    4. None of the mentioned

    Answer
  • 20.

    Which of the following is invalid assignment ?

    1. > x <- fact(c("yes", "yes", "no", "yes", "no"))

       

    2. > x <- factor(c("yes", "yes", "no", "yes", "no"))

       

    3. > x <- factor(factor("yes", "yes", "no", "yes", "no"))

       

    4. None of the mentioned

    Answer

© 2017 QuizBucket.org