Q. Which is the basic data structure of R containing the same type of data?

  • (A) Functions
  • (B) Array
  • (C) Vector
  • (D) Lists
πŸ’¬ Discuss
βœ… Correct Answer: (C) Vector

Q. What will be the output of the following R 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) [,5] [,6] [,7] [1,] 1 3 6 [2,] 2 4 5
πŸ’¬ Discuss
βœ… Correct Answer: (A) [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6

Q. What will be the output of the following R code?
> x <- data.frame(foo = 1:4, bar = c(T, T, F, F))
> ncol(x)

  • (A) 2
  • (B) 4
  • (C) 7
  • (D) 9
πŸ’¬ Discuss
βœ… Correct Answer: (A) 2

Q. Which of the following is invalid assignment?

  • (A) > x <- list("Los Angeles" = 1, Boston = 2, London = 3)
  • (B) > names(x) <- c("New York", "Seattle", "Los Angeles")
  • (C) > name(x) <- c("New York", "Seattle", "Los Angeles")
  • (D) > names(x) <- c("New York", "Los Angeles", "Los Angeles")
πŸ’¬ Discuss
βœ… Correct Answer: (C) > name(x) <- c("New York", "Seattle", "Los Angeles")

Q. Which function takes a dim attribute which creates the required number of dimensions?

  • (A) Vector
  • (B) Array
  • (C) Matrix
  • (D) Lists
πŸ’¬ Discuss
βœ… Correct Answer: (B) Array

Q. What will be the output of the following R code?
> x <- vector("list", length = 5)
> x

  • (A) NULL
  • (B) 1
  • (C) 0
  • (D) 4
πŸ’¬ Discuss
βœ… Correct Answer: (A) NULL

Q. 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) seq() function has four arguments
πŸ’¬ Discuss
βœ… Correct Answer: (B) Matrices are vectors with a dimension attribute

Q. To bind a row onto an already existing matrix, the . . . . . . . . function can be used.

  • (A) Rbind
  • (B) Sbnd
  • (C) Gbind
  • (D) Sbind
πŸ’¬ Discuss
βœ… Correct Answer: (A) Rbind

Q. vectors can be one of two types namely atomic vectors and . . . . . . . .

  • (A) Matrix
  • (B) Vector
  • (C) Lists
  • (D) Array
πŸ’¬ Discuss
βœ… Correct Answer: (C) Lists

Q. A . . . . . . . . is a set of elements appearing in rows and columns where the elements are of the same mode whether they are logical, numeric (integer or double), complex or character.

  • (A) Vector
  • (B) Matrix
  • (C) Lists
  • (D) Data frames
πŸ’¬ Discuss
βœ… Correct Answer: (B) Matrix