Q. Point out the wrong statement?

  • (A) for will execute a loop a fixed number of times
  • (B) break will execute a loop while a condition is true
  • (C) if and else tests a condition and acting on it
  • (D) break is used to break the execution of a loop
πŸ’¬ Discuss
βœ… Correct Answer: (B) break will execute a loop while a condition is true

Q. Point out the wrong statement?

  • (A) A formal argument can be a symbol, a statement of the form 'symbol = expression', or the special formal argument
  • (B) The first component of the function declaration is the keyword function
  • (C) The value returned by the call to function is not a function
  • (D) Functions are also often written when code must be shared with others or the public
πŸ’¬ Discuss
βœ… Correct Answer: (A) A formal argument can be a symbol, a statement of the form 'symbol = expression', or the special formal argument

Q. Point out the correct statement?

  • (A) Blocks are evaluated until a new line is entered after the closing brace
  • (B) Single statements are evaluated when a new line is typed at the start of the syntactically complete statement
  • (C) The if/else statement conditionally evaluates two statements
  • (D) Break will execute a loop while a condition is true
πŸ’¬ Discuss
βœ… Correct Answer: (C) The if/else statement conditionally evaluates two statements

Q. . . . . . . . . function can be used to add datasets in R provided with the columns in the datasets should be the same.

  • (A) rbind()
  • (B) bbind()
  • (C) jbind()
  • (D) hbind()
πŸ’¬ Discuss
βœ… Correct Answer: (A) rbind()

Q. If the programmers want the output to be a data frame or a vector, then . . . . . . . . function is used.

  • (A) Lapply
  • (B) Sapply
  • (C) Vapply
  • (D) Zapply
πŸ’¬ Discuss
βœ… Correct Answer: (A) Lapply

Q. A function, together with an environment, makes up what is called a . . . . . . . . closure.

  • (A) formal
  • (B) function
  • (C) reflective
  • (D) symmetry
πŸ’¬ Discuss
βœ… Correct Answer: (B) function

Q. Body of lapply function is?

  • (A) function (X, FUN, ...) { FUN <- match.fun(FUN) if (!is.vector(X) || is.object(X)) X <- as.list(X) .Internal(lapply(X, FUN)) }
  • (B) function (X, FUN, ...) { FUN <- match.fun(FUN) if (!is.vector(X) | is.object(X)) X <- as.list(X) .Internal(lapply(X, FUN)) }
  • (C) function (X, FUN, ...) { FUN <- match.fun(FUN) if (is.vector(X) || is.object(X)) X <- as.list(X) .Internal(lapply(X, FUN)) }
  • (D) function (X, FUN, ...) { FUN <- match.fun(FUN) if (is.vector(X) || is.object(X)) }
πŸ’¬ Discuss
βœ… Correct Answer: (A) function (X, FUN, ...) { FUN <- match.fun(FUN) if (!is.vector(X) || is.object(X)) X <- as.list(X) .Internal(lapply(X, FUN)) }

Q. . . . . . . . . is used to break the execution of a loop.

  • (A) next
  • (B) skip
  • (C) break
  • (D) delete
πŸ’¬ Discuss
βœ… Correct Answer: (C) break

Q. Write a function to extract the first name in the string "Mrs. Jake Luther"?

  • (A) Substring
  • (B) Substr
  • (C) Substi
  • (D) Return
πŸ’¬ Discuss
βœ… Correct Answer: (B) Substr

Q. Which of the following R code will print the following result?
[[1]]
[1] 2.263808
[[2]]
[1] 1.314165 9.815635
[[3]]
[1] 3.270137 5.069395 6.814425
[[4]]
[1] 0.9916910 1.1890256 0.5043966 9.2925392

  • (A) > x <- 1:4 > lapply(x, runif, min = 0, max = 10)
  • (B) > x <- 1:4 > lapply(x, runif, min = 0, max = 9)
  • (C) > x <- 1:3 > lapply(x, runif, min = 0, max = 10)
  • (D) > x <- 1:4 > lapply(x, runif, min = 0, max = 6)
πŸ’¬ Discuss
βœ… Correct Answer: (A) > x <- 1:4 > lapply(x, runif, min = 0, max = 10)