Q. In R, how do you create a list named my_list with three elements: 1, "hello", and TRUE?

  • (A) my_list <- c(1, "hello", TRUE)
  • (B) my_list = list(1, "hello", TRUE)
  • (C) my_list(1, "hello", TRUE)
  • (D) list(my_list = c(1, "hello", TRUE))
πŸ’¬ Discuss
βœ… Correct Answer: (B) my_list = list(1, "hello", TRUE)

Q. What is the primary data structure used for storing tabular data in R?

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

Q. How is a vector different from a list in R?

  • (A) Vectors can only store numeric values
  • (B) Lists can store elements of different types
  • (C) Lists can only store characters
  • (D) Vectors can store elements of different types
πŸ’¬ Discuss
βœ… Correct Answer: (D) Vectors can store elements of different types

Q. In R, how is a matrix initialized with values 1 to 9 arranged in three rows?

  • (A) matrix(1:9, nrow = 3, ncol = 3)
  • (B) matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3)
  • (C) matrix(1:9, rows = 3, cols = 3)
  • (D) mat(1:9, 3, 3)
πŸ’¬ Discuss
βœ… Correct Answer: (A) matrix(1:9, nrow = 3, ncol = 3)

Q. How do you create a factor in R named color with levels "red", "green", and "blue"?

  • (A) factor(color, levels = c("red", "green", "blue"))
  • (B) factor(color, levels = "red", "green", "blue")
  • (C) factor(color = c("red", "green", "blue"))
  • (D) factor(color = c("red", "green", "blue"), levels = c("red", "green", "blue"))
πŸ’¬ Discuss
βœ… Correct Answer: (D) factor(color = c("red", "green", "blue"), levels = c("red", "green", "blue"))

Q. What is the purpose of the data.frame() function in R?

  • (A) Create a vector
  • (B) Create a data frame
  • (C) Create a matrix
  • (D) Create a list
πŸ’¬ Discuss
βœ… Correct Answer: (B) Create a data frame

Q. In R, how do you create a named list with elements "apple", "orange", and "banana"?

  • (A) list("apple", "orange", "banana")
  • (B) named_list(c("apple", "orange", "banana"))
  • (C) list(c("apple", "orange", "banana"))
  • (D) list(elements = c("apple", "orange", "banana"))
πŸ’¬ Discuss
βœ… Correct Answer: (D) list(elements = c("apple", "orange", "banana"))

Q. What is the correct way to access the second element of a vector named my_vector in R?

  • (A) my_vector(2)
  • (B) my_vector[2]
  • (C) my_vector.2
  • (D) my_vector[[2]]
πŸ’¬ Discuss
βœ… Correct Answer: (B) my_vector[2]

Q. The only environment without a parent is the . . . . . . . . environment.

  • (A) full
  • (B) half
  • (C) null
  • (D) empty
πŸ’¬ Discuss
βœ… Correct Answer: (D) empty

Q. The . . . . . . . . function is a kind of "constructor function" that can be used to construct other functions.

  • (A) make.pow()
  • (B) make.power()
  • (C) keep.power()
  • (D) keep.pow()
πŸ’¬ Discuss
βœ… Correct Answer: (B) make.power()