Q. What is the output of the following R code: for (i in 1:5) { if (i %% 2 == 0) { print(i) } }

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

Q. In R, what is the purpose of the repeat loop combined with break?

  • (A) To create an infinite loop
  • (B) To repeat a block of code until a certain condition is met
  • (C) To skip the current iteration of the loop
  • (D) To exit the loop immediately
πŸ’¬ Discuss
βœ… Correct Answer: (D) To exit the loop immediately

Q. How is the switch() function different from if-else in R?

  • (A) switch() is used for multiple conditions, if-else for two conditions
  • (B) switch() can only handle numeric values, if-else can handle any type
  • (C) if-else can only handle numeric values, switch() can handle any type
  • (D) Both switch() and if-else are used interchangeably
πŸ’¬ Discuss
βœ… Correct Answer: (A) switch() is used for multiple conditions, if-else for two conditions

Q. What is the role of the next statement in a loop in R?

  • (A) To skip the next condition in an if-else statement
  • (B) To exit the loop immediately
  • (C) To move to the next iteration of the loop
  • (D) To restart the loop from the beginning
πŸ’¬ Discuss
βœ… Correct Answer: (C) To move to the next iteration of the loop

Q. In R, what does the repeat loop combined with next do?

  • (A) Repeats a block of code indefinitely and skips to the next iteration when a condition is met
  • (B) Repeats a block of code a specified number of times and exits the loop immediately
  • (C) Repeats a block of code a specified number of times and skips to the next iteration
  • (D) Repeats a block of code indefinitely and exits the loop immediately
πŸ’¬ Discuss
βœ… Correct Answer: (C) Repeats a block of code a specified number of times and skips to the next iteration

Q. What is the role of exploratory graphs in data analysis?

  • (A) They are made for formal presentations
  • (B) They are typically made very quickly
  • (C) Axes, legends, and other details are clean and exactly detailed
  • (D) They are used in place of formal modeling
πŸ’¬ Discuss
βœ… Correct Answer: (B) They are typically made very quickly

Q. . . . . . . . . evaluate the cumulative distribution function for a Normal distribution.

  • (A) dnorm
  • (B) rnorm
  • (C) pnorm
  • (D) rpois
πŸ’¬ Discuss
βœ… Correct Answer: (C) pnorm

Q. What will be the output of the following R code?
> set.seed(20)
> x <- rnorm(100)
> e <- rnorm(100, 0, 2)
> y <- 0.5 + 2 * x + e
> summary(y)

  • (A) Min. 1st Qu. Median Mean 3rd Qu. Max. -6.4080 -1.5400 0.6789 0.6893 2.9300 6.5050
  • (B) Min. 1st Qu. Median Mean 3rd Qu. Max. -6.4080 -10.5400 0.6789 5.6893 2.9300 6.5050
  • (C) Min. 1st Qu. Median Mean 3rd Qu. Max. -1.4080 -6.5400 0.6789 0.6893 2.9300 6.5050
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (A) Min. 1st Qu. Median Mean 3rd Qu. Max. -6.4080 -1.5400 0.6789 0.6893 2.9300 6.5050

Q. . . . . . . . . describe the type of plot you will produce.

  • (A) geoms
  • (B) ggplot
  • (C) fplot
  • (D) gplot
πŸ’¬ Discuss
βœ… Correct Answer: (A) geoms

Q. . . . . . . . . is used for translating between qplot and base graphics.

  • (A) translate_qplot_base
  • (B) translate_qplot_gpl
  • (C) translate_qplot_lattice
  • (D) translate_qplot_ggplot
πŸ’¬ Discuss
βœ… Correct Answer: (A) translate_qplot_base