Q. . . . . . . . . function gives an error message if the desired package cannot be loaded.

  • (A) Dplyr
  • (B) Require
  • (C) Library
  • (D) Sample
πŸ’¬ Discuss
βœ… Correct Answer: (C) Library

Q. What will be the output of the following R code?
> x <- list(a = 1:5, b = rnorm(10))
> lapply(x, mean)

  • (A) $a [1] 3 $b [1] 0.1322028
  • (B) $a [1] 4 $b [1] 0.1322028
  • (C) $a [1] 5 $b [1] 0.1322028
  • (D) $a [2] 5 $b [1] 3
πŸ’¬ Discuss
βœ… Correct Answer: (A) $a [1] 3 $b [1] 0.1322028

Q. Which of the following R code syntax is syntactically valid?

  • (A) if ( statement1 ) { statement2 } else if ( statement3 ) { statement4 } else if ( statement5 ) { statement6 } else statement8
  • (B) if ( statement1 ) { statement2 } elseif ( statement3 ) { statement4 } elseif ( statement5 ) { statement6 } else statement8
  • (C) if ( statement1 ) { statement2 } elseif ( statement3 ) { statement4 } else if ( statement5 ) { statement6 } else statement8
  • (D) if ( statement1 ) { statement2 } else if ( statement5 ) { statement6 } else statement8
πŸ’¬ Discuss
βœ… Correct Answer: (A) if ( statement1 ) { statement2 } else if ( statement3 ) { statement4 } else if ( statement5 ) { statement6 } else statement8

Q. . . . . . . . . function takes various parameters like formula, data, subset, labels, etc.

  • (A) Pears
  • (B) Pairs
  • (C) Tears
  • (D) Cars
πŸ’¬ Discuss
βœ… Correct Answer: (B) Pairs

Q. . . . . . . . . functions can be "built which contain all of the necessary data for evaluating the function.

  • (A) Objective
  • (B) reflective
  • (C) Nested
  • (D) Symmetry
πŸ’¬ Discuss
βœ… Correct Answer: (A) Objective

Q. . . . . . . . . loop over a list and evaluate a function on each element.

  • (A) apply()
  • (B) lapply()
  • (C) sapply()
  • (D) mapply()
πŸ’¬ Discuss
βœ… Correct Answer: (A) apply()

Q. Point out the correct statement?

  • (A) The next statement causes an exit from the innermost loop that is currently being executed
  • (B) There are two statements that can be used to explicitly control looping
  • (C) The break statement immediately causes control to return to the start of the loop
  • (D) Computation in R consists of sequentially evaluating statements
πŸ’¬ Discuss
βœ… Correct Answer: (B) There are two statements that can be used to explicitly control looping

Q. Point out the correct statement?

  • (A) Statements, such as x<-1:10 or mean(y), can be separated by either a semicolon or a new line
  • (B) Whenever the evaluator is presented with a syntactically complete statement that statement is evaluated and the value returned
  • (C) Computation in R consists of sequentially evaluating statements
  • (D) All of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the mentioned

Q. What will be the output of the following R code?
> printmessage <- function(x) {
+ if(x > 0)
+ print("x is greater than zero")
+ else
+ print("x is less than or equal to zero")
+ invisible(x)
+ }
> printmessage(NA)

  • (A) Error
  • (B) Warning
  • (C) Messages
  • (D) Null
πŸ’¬ Discuss
βœ… Correct Answer: (A) Error

Q. Point out the wrong statement?

  • (A) The sapply() function behaves similarly to lapply()
  • (B) With multiple factors and many levels, creating an interaction can result in many levels that are empty
  • (C) apply() can be thought of as a combination of split() and sapply() for vectors only
  • (D) You can use tsplit() to evaluate a function single time each with a same argument
πŸ’¬ Discuss
βœ… Correct Answer: (C) apply() can be thought of as a combination of split() and sapply() for vectors only