Q. What will be the output of the following R code?
> m <- 1:10
> m

  • (A) 1 2 3 4 5 6 7 8 9 10
  • (B) 1 2 3 4 5 6 7 8 9 10 11
  • (C) 0 1 2 3 4 5 6 7 8 9 10
  • (D) 10 9 8 6 5 4 2 3 1 2
πŸ’¬ Discuss
βœ… Correct Answer: (A) 1 2 3 4 5 6 7 8 9 10

Q. What should we use to access elements with a value greater than five?

  • (A) Subsetting commands
  • (B) Use functions
  • (C) Packages
  • (D) Interfaces
πŸ’¬ Discuss
βœ… Correct Answer: (A) Subsetting commands

Q. Lists can be coerced with which function?

  • (A) As.lists
  • (B) Has.lists
  • (C) In.lists
  • (D) Co.lists
πŸ’¬ Discuss
βœ… Correct Answer: (A) As.lists

Q. Which dimension corresponds to the explanatory variables collected for each species?

  • (A) First
  • (B) Second
  • (C) Third
  • (D) Fifth
πŸ’¬ Discuss
βœ… Correct Answer: (B) Second

Q. What will be the output of the following R code?
> m <- matrix(nrow = 2, ncol = 3)
> dim(m)

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

Q. What will be the output of the following R code?
> x <- factor(c("yes", "yes", "no", "yes", "no"))
> table(x)

  • (A) no yes 2 3
  • (B) yes no 2 3
  • (C) no yes 2 2
  • (D) yes yes 6 2
πŸ’¬ Discuss
βœ… Correct Answer: (A) no yes 2 3

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

  • (A) Returns the sum of elements
  • (B) Returns the number of elements
  • (C) Computes the length of a vector
  • (D) Calculates the mean of a vector
πŸ’¬ Discuss
βœ… Correct Answer: (B) Returns the number of elements

Q. In R, how do you create a sequence of even numbers from 2 to 10?

  • (A) seq(2, 10, by = 2)
  • (B) seq_even(2, 10)
  • (C) even_seq(2, 10)
  • (D) seq(2, 10)
πŸ’¬ Discuss
βœ… Correct Answer: (A) seq(2, 10, by = 2)

Q. What does the sort() function do in R?

  • (A) Arrange elements in ascending order
  • (B) Shuffle the elements randomly
  • (C) Reverse the order of elements
  • (D) Sort elements in descending order
πŸ’¬ Discuss
βœ… Correct Answer: (A) Arrange elements in ascending order

Q. How do you calculate the mean of a numeric vector in R?

  • (A) mean(vector)
  • (B) average(vector)
  • (C) vec_mean(vector)
  • (D) calc_mean(vector)
πŸ’¬ Discuss
βœ… Correct Answer: (A) mean(vector)